コード例 #1
0
        public SaveResult <POEntryModel> Save(PODTO pODTO, DateTime dateStamp)
        {
            if (pODTO.Status_FK == 0)
            {
                pODTO.Status_FK = 1;
            }

            ModelValidationResult validationResult = POValidator.Validate(pODTO);
            bool         success = false;
            POEntryModel model   = null;

            if (validationResult.IsValid)
            {
                tblT_PO po = Insert(pODTO, dateStamp);
                Db.SaveChanges();
                pODTO.PO_PK = po.PO_PK;

                success = true;
                model   = POEntryDataProvider.Get(pODTO.PO_PK);
            }

            return(new SaveResult <POEntryModel>
            {
                Success = success,
                Message = validationResult.IsValid ? "Data successfully created." : "Validation error occured.",
                Model = model,
                ValidationResult = validationResult
            });
        }
コード例 #2
0
 public IHttpActionResult GetForm(int id)
 {
     //string accessType = "PO_ViewAll";
     //if (id > 0)
     //    ThrowIfUserHasNoRole(accessType);
     using (POEntryDataProvider poEntryDataProvider = new POEntryDataProvider(Db, ActiveUser, new POQuery(Db)))
     {
         var data = poEntryDataProvider.Get(id);
         SaveLog("PO", "GetForm", JsonConvert.SerializeObject(new { primaryKey = id }));
         return(Ok(new SuccessResponse(data)));
     }
 }
コード例 #3
0
        public SaveResult <POEntryModel> Save(PODTO pODTO, DateTime dateStamp)
        {
            ModelValidationResult validationResult = pOValidator.Validate(pODTO);
            bool         success = false;
            POEntryModel model   = null;

            if (validationResult.IsValid)
            {
                success = true;
                UpdatePO(pODTO, dateStamp);
                Db.SaveChanges();
                model = pOEntryDataProvider.Get(pODTO.PO_PK);
            }

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