private void SoftDelete(tblM_BTSTechnology btsTechnology)
 {
     if (btsTechnology != null)
     {
         btsTechnology.Status_FK = (int)RecordStatus.Deleted;
     }
 }
 private void HardDelete(tblM_BTSTechnology btsTechnology)
 {
     if (btsTechnology != null)
     {
         Db.tblM_BTSTechnology.Remove(btsTechnology);
     }
 }
示例#3
0
 public void Update(BTSTechnologyDTO btsTechnologyDTO, DateTime dateStamp)
 {
     if (btsTechnologyDTO == null)
     {
         throw new ArgumentNullException("BTSTechnology model is null.");
     }
     tblM_BTSTechnology btsTechnology = btsTechnologyFactory.CreateFromDbAndUpdateFromDTO(btsTechnologyDTO, dateStamp);
 }
        public tblM_BTSTechnology Insert(BTSTechnologyDTO btsTechnologyDTO, DateTime dateStamp)
        {
            if (btsTechnologyDTO == null)
            {
                throw new ArgumentNullException("BTSTechnology model is null.");
            }
            tblM_BTSTechnology btsTechnology = btsTechnologyFactory.CreateFromDTO(btsTechnologyDTO, dateStamp);

            return(Db.tblM_BTSTechnology.Add(btsTechnology));
        }
示例#5
0
        public tblM_BTSTechnology AddBTSTechno(BTSTechnologyDTO btstDTO, DateTime dateStamp)
        {
            if (btstDTO == null)
            {
                throw new ArgumentNullException("BTS model is null.");
            }
            tblM_BTSTechnology btst = btstFactory.CreateFromDTO(btstDTO, dateStamp);

            btst = Db.tblM_BTSTechnology.Add(btst);
            return(btst);
        }
示例#6
0
        public tblM_BTSTechnology CreateFromDTO(BTSTechnologyDTO btsTechnologyDTO, DateTime dateStamp)
        {
            if (btsTechnologyDTO == null)
            {
                throw new ArgumentNullException("BTSTechnology model is null.");
            }
            btsTechnologyDTO.Status_FK   = (int)RecordStatus.Active;
            btsTechnologyDTO.CreatedBy   = User.Username;
            btsTechnologyDTO.CreatedDate = dateStamp;
            btsTechnologyDTO.UpdatedBy   = User.Username;
            btsTechnologyDTO.UpdatedDate = dateStamp;
            tblM_BTSTechnology btsTechnology = btsTechnologyDTO.ToObject <tblM_BTSTechnology>();

            return(btsTechnology);
        }
示例#7
0
        public void AddBTSTechnologies(BTSDTO btsDTO, DateTime dateStamp)
        {
            if (btsDTO == null)
            {
                throw new ArgumentNullException("BTS model is null.");
            }
            foreach (var btsTechnologyDTO in btsDTO.BTSTechnologies)
            {
                var factory = new BTSTechnologyFactory(Db, User);

                tblM_BTSTechnology btsTechnology = factory.CreateFromDTO(btsTechnologyDTO, dateStamp);
                btsTechnology.BTS_FK = btsDTO.BTS_PK;
                btsTechnology        = Db.tblM_BTSTechnology.Add(btsTechnology);
            }
        }
        public SaveResult <BTSTechnologyEntryModel> Save(BTSTechnologyDTO btsTechnologyDTO, DateTime dateStamp)
        {
            ModelValidationResult validationResult = btsTechnologyValidator.Validate(btsTechnologyDTO);
            bool success = false;
            BTSTechnologyEntryModel model = null;

            if (validationResult.IsValid)
            {
                tblM_BTSTechnology btsTechnology = Insert(btsTechnologyDTO, dateStamp);
                Db.SaveChanges();

                success = true;
                model   = btsTechnologyEntryDataProvider.Get(btsTechnology.BTSTechnology_PK);
            }

            return(new SaveResult <BTSTechnologyEntryModel>
            {
                Success = success,
                Message = validationResult.IsValid ? "Data successfully created." : "Validation error occured.",
                Model = model,
                ValidationResult = validationResult
            });
        }
        public DeleteResult <tblM_BTSTechnology> Execute(int btsTechnologyPK, DeleteMethod deleteMethod)
        {
            tblM_BTSTechnology btsTechnology = Db.tblM_BTSTechnology.Find(btsTechnologyPK);

            if (btsTechnology == null)
            {
                return(new DeleteResult <tblM_BTSTechnology>()
                {
                    Success = false,
                    Message = $"Id '{btsTechnologyPK}' is not found.",
                    Record = null
                });
            }

            switch (deleteMethod)
            {
            case DeleteMethod.Soft:
                SoftDelete(btsTechnology);
                break;

            case DeleteMethod.Hard:
                HardDelete(btsTechnology);
                break;

            default:
                break;
            }

            Db.SaveChanges();

            return(new DeleteResult <tblM_BTSTechnology>()
            {
                Success = true,
                Message = $"BTSTechnology with Id '{btsTechnologyPK}' successfully deleted.",
                Record = btsTechnology
            });
        }