Пример #1
0
        public IActionResult SaveLocation(LocationToGetOrderOfUser locationToGetOrderOfUser)
        {
            bool   result    = true;
            string message   = string.Empty;
            var    userEmail = User.GetSpecificClaim("Email");

            if (ModelState.IsValid)
            {
                locationToGetOrderOfUser.UserModified = userEmail;

                if (locationToGetOrderOfUser.Id == 0)
                {
                    locationToGetOrderOfUser.UserCreated = userEmail;
                    _locationToGetOrderOfUserService.Add(locationToGetOrderOfUser, out result, out message);
                }
                else
                {
                    _locationToGetOrderOfUserService.UpdateChangedProperties(locationToGetOrderOfUser, out result, out message);
                }

                return(new OkObjectResult(new GenericResult(result, message)));
            }
            else
            {
                List <string> listErrors  = ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage).ToList();
                string        errorString = String.Join("\n", listErrors.ToArray());
                return(new OkObjectResult(new GenericResult(false, errorString)));
            }
        }
Пример #2
0
 public void Add(LocationToGetOrderOfUser locationToGetOrderOfUser, out bool result, out string message)
 {
     _locationToGetOrderOfUserRepository.Add(locationToGetOrderOfUser, out result, out message);
     if (result)
     {
         SaveChanges();
     }
     else
     {
         Dispose();
     }
 }
Пример #3
0
 public void UpdateChangedProperties(LocationToGetOrderOfUser locationToGetOrderOfUser, out bool result, out string message)
 {
     _locationToGetOrderOfUserRepository.UpdateChangedProperties(locationToGetOrderOfUser.Id, locationToGetOrderOfUser, out result, out message);
     if (result)
     {
         SaveChanges();
     }
     else
     {
         Dispose();
     }
 }