private void SoftDelete(tblM_IzinCutiStatus izinCutiStatus)
 {
     if (izinCutiStatus != null)
     {
         izinCutiStatus.Status_FK = (int)RecordStatus.Deleted;
     }
 }
 private void HardDelete(tblM_IzinCutiStatus izinCutiStatus)
 {
     if (izinCutiStatus != null)
     {
         Db.tblM_IzinCutiStatus.Remove(izinCutiStatus);
     }
 }
 public void Update(IzinCutiStatusDTO izinCutiStatusDTO, DateTime dateStamp)
 {
     if (izinCutiStatusDTO == null)
     {
         throw new ArgumentNullException("IzinCutiStatus model is null.");
     }
     tblM_IzinCutiStatus izinCutiStatus = izinCutiStatusFactory.CreateFromDbAndUpdateFromDTO(izinCutiStatusDTO, dateStamp);
 }
예제 #4
0
        public tblM_IzinCutiStatus Insert(IzinCutiStatusDTO izinCutiStatusDTO, DateTime dateStamp)
        {
            if (izinCutiStatusDTO == null)
            {
                throw new ArgumentNullException("IzinCutiStatus model is null.");
            }
            tblM_IzinCutiStatus izinCutiStatus = izinCutiStatusFactory.CreateFromDTO(izinCutiStatusDTO, dateStamp);

            return(Db.tblM_IzinCutiStatus.Add(izinCutiStatus));
        }
        public tblM_IzinCutiStatus CreateFromDTO(IzinCutiStatusDTO izinCutiStatusDTO, DateTime dateStamp)
        {
            if (izinCutiStatusDTO == null)
            {
                throw new ArgumentNullException("IzinCutiStatus model is null.");
            }
            izinCutiStatusDTO.Status_FK   = (int)RecordStatus.Active;
            izinCutiStatusDTO.CreatedBy   = User.Username;
            izinCutiStatusDTO.CreatedDate = dateStamp;
            izinCutiStatusDTO.UpdatedBy   = User.Username;
            izinCutiStatusDTO.UpdatedDate = dateStamp;
            tblM_IzinCutiStatus izinCutiStatus = izinCutiStatusDTO.ToObject <tblM_IzinCutiStatus>();

            return(izinCutiStatus);
        }
예제 #6
0
        public SaveResult <IzinCutiStatusEntryModel> Save(IzinCutiStatusDTO izinCutiStatusDTO, DateTime dateStamp)
        {
            ModelValidationResult validationResult = izinCutiStatusValidator.Validate(izinCutiStatusDTO);
            bool success = false;
            IzinCutiStatusEntryModel model = null;

            if (validationResult.IsValid)
            {
                tblM_IzinCutiStatus izinCutiStatus = Insert(izinCutiStatusDTO, dateStamp);
                Db.SaveChanges();

                success = true;
                model   = izinCutiStatusEntryDataProvider.Get(izinCutiStatus.IzinCutiStatus_PK);
            }

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

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

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

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

            default:
                break;
            }

            Db.SaveChanges();

            return(new DeleteResult <tblM_IzinCutiStatus>()
            {
                Success = true,
                Message = $"IzinCutiStatus with Id '{izinCutiStatusPK}' successfully deleted.",
                Record = izinCutiStatus
            });
        }