Exemplo n.º 1
0
        private void UpdateSowAssign(SOWApprovalDTO sowApprovalDTO, DateTime dateStamp)
        {
            if (sowApprovalDTO == null)
            {
                throw new ArgumentNullException("SOW model is null.");
            }

            var sowAssigns = Db.tblT_SOWAssign.Where(x => x.SOW_FK == sowApprovalDTO.SOW_PK);

            foreach (var sowAssign in sowAssigns)
            {
                sowAssign.TglSelesai = dateStamp;
            }
        }
Exemplo n.º 2
0
        public void UpdateSOW(SOWApprovalDTO sowApprovalDTO, DateTime dateStamp)
        {
            if (sowApprovalDTO == null)
            {
                throw new ArgumentNullException("SOW model is null.");
            }
            tblT_SOW sow = Db.tblT_SOW.Find(sowApprovalDTO.SOW_PK);

            if (sow != null)
            {
                //if (sow.TglSelesai != null)
                //{
                //    throw new Kairos.KairosException("Cannot make an approval because this SOW already has an approval.");
                //}

                sow.TglSelesai   = dateStamp;
                sow.StatusSOW_FK = sowApprovalDTO.StatusSOW_FK;
            }
        }
Exemplo n.º 3
0
        public SaveResult <SOWEntryModel> Save(SOWApprovalDTO sowApprovalDTO, DateTime dateStamp)
        {
            ModelValidationResult validationResult = sowValidator.ValidateApprovalModel(sowApprovalDTO);
            bool          success = false;
            SOWEntryModel model   = null;

            if (validationResult.IsValid)
            {
                success = true;
                UpdateSOW(sowApprovalDTO, dateStamp);
                UpdateSowAssign(sowApprovalDTO, dateStamp);
                SaveChanges();

                model = sowEntryDataProvider.Get(sowApprovalDTO.SOW_PK);
            }

            return(new SaveResult <SOWEntryModel>
            {
                Success = success,
                Message = validationResult.IsValid ? "Data successfully updated." : "Validation error occured.",
                Model = model,
                ValidationResult = validationResult
            });
        }