Beispiel #1
0
        public void Create(StocktakingPlanModel model)
        {
            var entity = model.MapTo <StocktakingPlan>();

            entity.CreatedBy     = model.EditedBy;
            entity.CreatedByName = model.Editor;
            entity.UpdatedBy     = model.EditedBy;
            entity.UpdatedByName = model.Editor;
            entity.Code          = _billService.GenerateNewCode(BillIdentity.StoreStocktakingPlan);
            _service.ValidatePlan(entity);
            _service.ValidatePlanDate(entity);
            _db.Insert(entity);
            _db.SaveChange();
        }
Beispiel #2
0
        public void Edit(StocktakingPlanModel model)
        {
            var entity             = _db.Table.Find <StocktakingPlan>(model.Id);
            var oldStocktakingDate = entity.StocktakingDate;

            entity               = model.MapTo <StocktakingPlan>(entity);
            entity.UpdatedBy     = model.EditedBy;
            entity.UpdatedByName = model.Editor;
            entity.UpdatedOn     = DateTime.Now;
            _service.ValidatePlan(entity);
            if (oldStocktakingDate != entity.StocktakingDate)
            {
                _service.ValidatePlanDate(entity);
            }
            _db.Update(entity);
            _db.SaveChange();
        }