protected Crop(CropType type, Surface surface, Planification planification , Code physicalBlock, Code parcel) : this(Guid.NewGuid()) { this.Type = type; this.Surface = surface; this.Planification = planification; this.Parcel = parcel; this.PhysicalBlock = physicalBlock; }
/// <summary> /// Factory method /// </summary> /// <param name="type"></param> /// <param name="surface"></param> /// <returns>A new instance of Crop.</returns> public static Crop Create(CropType type, Surface surface, Planification planification , Code physicalBlock, Code parcel) { _ = type ?? throw new ArgumentNullException(); _ = surface ?? throw new ArgumentNullException(); _ = planification ?? throw new ArgumentNullException(); _ = physicalBlock ?? throw new ArgumentNullException(); _ = parcel ?? throw new ArgumentNullException(); return(new Crop(type, surface, planification, physicalBlock, parcel)); }
public virtual void AddCrop(CropType type, Surface surface , Code physicalBlock, Code parcel) { if (surface.Value <= 0) { throw new InvalidValueException("Value must be grater then 0!"); } var crop = Crop.Create(type, surface, this, physicalBlock, parcel); crop.State = TrackingState.Added; _crops.Add(crop); this.Surface = this.Surface.Decrease(surface.Value); }