public IHttpActionResult GetForm(int id)
 {
     if (id > 0)
     {
         ThrowIfUserHasNoRole(readRole);
     }
     using (DeliveryAreaEntryDataProvider deliveryAreaEntryDataProvider = new DeliveryAreaEntryDataProvider(Db, ActiveUser, AccessControl, new DeliveryAreaQuery(Db)))
     {
         var data = deliveryAreaEntryDataProvider.Get(id);
         SaveLog("DeliveryArea", "GetForm", JsonConvert.SerializeObject(new { primaryKey = id }));
         return(Ok(new SuccessResponse(data)));
     }
 }
Beispiel #2
0
        public SaveResult <DeliveryAreaEntryModel> Save(DeliveryAreaDTO deliveryAreaDTO, DateTime dateStamp)
        {
            ModelValidationResult validationResult = deliveryAreaValidator.Validate(deliveryAreaDTO);
            bool success = false;
            DeliveryAreaEntryModel model = null;

            if (validationResult.IsValid)
            {
                success = true;
                Update(deliveryAreaDTO, dateStamp);
                Db.SaveChanges();
                model = deliveryAreaEntryDataProvider.Get(deliveryAreaDTO.DeliveryArea_PK);
            }

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