On 14 Set, 19:47, Jason Meckley <[email protected]> wrote:
> "PS: you'll probably need the code (class+mapping) to give me any real
> help"
> your right...
>
> "can I post them here?"
> yes you can....
>
> "how?"
> copy and paste.
Thanks, just wasn't sure and didn't want to "pollute" the place with a
lot of code.. here it comes...
My POCOs:
- public abstract class ModelBase
an empty abstract class, no need to paste it here
- public abstract class GenericModelBase<TId> : ModelBase
an abstract class deriving from ModelBase, it has just 1 property
- public virtual TId Id { get; protected set; }
- public abstract class VersionModelBase : GenericModelBase<long>
another abstact base class with just 2 properties used for
versioning and soft deleted
- public virtual long Version { get; set; }
- public virtual DateTime? DeletedOn { get; set; }
- and finally the class giving problems (there's a mix of italian and
english in some of the names... hope it doesn't bother you too much)
using System;
using System.Collections.Generic;
using System.Linq;
using Iesi.Collections.Generic;
using LZerp.Model.Base;
using LZerp.Model.Tags;
namespace LZerp.Model.Quotations
{
public enum PrinterType
{
Cd4C,
Cd5C
}
public enum PaperCostType
{
Weight,
Sheet
}
[Flags]
public enum CostOptions
{
//None = 0,
Plasticization = 1,
UVPainting = 1 << 1,
CreasingDie = 1 << 2, // Cordonatura/Fustellatura
ConfTaglio = 1 << 3, // TODO Conf taglio ecc
ConfPM = 1 << 4, // TODO Conf PM
ConfBrossura = 1 << 5, // TODO Conf brossura refe
Transport = 1 << 6,
Packaging = 1 << 7,
Various = 1 << 8
}
public class ProductQuotation : VersionModelBase
{
protected ProductQuotation() : this(null, null)
{
}
public ProductQuotation(Quotation quotation, string name) :
this(quotation, name, null)
{
}
public ProductQuotation(Quotation quotation, string name, string
group)
{
// ReSharper disable
DoNotCallOverridableMethodsInConstructor
Quotation = quotation;
Name = name;
Group = group;
// ReSharper restore
DoNotCallOverridableMethodsInConstructor
Editions = new HashedSet<EditionQuotation>();
}
public virtual Quotation Quotation { get; protected set; }
public virtual string Name { get; set; }
public virtual string Group { get; set; }
public virtual string Description { get; set; }
/// <summary>
/// Formato rifilato
/// </summary>
public virtual string Format { get; set; }
/// <summary>
/// Colore
/// </summary>
public virtual string Color { get; set; }
/// <summary>
/// CD 4 C, CD 5 C
/// </summary>
public virtual PrinterType PrinterType { get; set; }
/// <summary>
/// Tipo di carta
/// </summary>
public virtual string PaperType { get; set; }
/// <summary>
/// Grammatura
/// </summary>
public virtual string PaperWeight { get; set; }
/// <summary>
/// Formato carta
/// </summary>
public virtual PaperFormat PaperFormat { get; set; }
/// <summary>
/// Formato stampa
/// </summary>
public virtual PrintFormat PrintFormat { get; set; }
/// <summary>
/// Costo al kg/foglio
/// </summary>
public virtual PaperCostType PaperCostType { get; set; }
/// <summary>
/// Costo al... (come specificato da PapertCostType)
/// </summary>
public virtual decimal PaperUnitCost { get; set; }
/// <summary>
/// Peso risma
/// </summary>
public virtual decimal PaperReamWeight { get; set; }
/// <summary>
/// Grafica
/// </summary>
public virtual decimal GraphicCost { get; set; }
/// <summary>
/// Impianto fotolito
/// </summary>
public virtual decimal PhotolithographyEquipmentCost { get;
set; }
/// <summary>
/// Opzioni attive
/// </summary>
public virtual CostOptions CostOptions { get; set; }
public virtual Iesi.Collections.Generic.ISet<EditionQuotation>
Editions { get; protected set; }
#region CostOption management methods
public virtual bool HasCostOption(CostOptions costOption)
{
return (CostOptions & costOption) == costOption;
}
public virtual void AddCostOption(CostOptions costOption)
{
CostOptions |= costOption;
}
public virtual void RemoveCostOption(CostOptions costOption)
{
CostOptions &= ~costOption;
}
#endregion
#region Editions management methods
protected internal virtual int[] GetEditionCopyCounts()
{
return Editions.Select(edition =>
edition.CopyCount).ToArray();
}
protected internal virtual EditionQuotation AddEdition(int
copyCount)
{
if (GetEditionCopyCounts().Contains(copyCount))
throw new ApplicationException("Edition with
same copy count is
already present");
var result = new EditionQuotation(this, copyCount);
Editions.Add(result);
return result;
}
protected internal virtual EditionQuotation RemoveEdition(int
copyCount)
{
var removed = Editions.FirstOrDefault(edition =>
edition.CopyCount
== copyCount);
if (removed == null)
throw new ApplicationException("Edition with
same copy count is
not present");
Editions.Remove(removed);
return removed;
}
public virtual EditionQuotation GetEditionByCopyCount(int
copyCount)
{
return Editions.FirstOrDefault(edition =>
edition.CopyCount ==
copyCount);
}
#endregion
}
}
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.