예제 #1
0
        public async Task Update(core.Planification plan)
        {
            var exist = _context.Planifications.Any(x => x.Id == plan.Id);

            if (!exist)
            {
                await _context.Planifications.AddAsync(plan);
            }

            foreach (core.Crop crop in plan.Crops)
            {
                switch (crop.State)
                {
                case TrackingState.Added:
                    _context.Entry(crop).State = EntityState.Added; break;

                case TrackingState.Modified:
                    _context.Entry(crop).State = EntityState.Modified; break;

                case TrackingState.Removed:
                    _context.Entry(crop).State = EntityState.Deleted; break;

                default:
                    break;
                }
                ;
            }
            await Uow.SaveChangesAsync(default(CancellationToken));
        }
예제 #2
0
 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;
 }
예제 #3
0
        /// <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));
        }