コード例 #1
0
 public ActionResult Details(int id, RegisteredClientViewModel collection)
 {
     try
     {
         if (id > 0)
         {
             _registeredClientService.Delete(_mapper.Map <RegisteredClient>(collection));
             return(RedirectToAction("Index"));
         }
         ModelState.AddModelError(string.Empty, GeneralMessages.EmptyId);
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
         }
     }
     return(View(collection));
 }
コード例 #2
0
        public ActionResult Edit(RegisteredClientViewModel collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var model = _mapper.Map <RegisteredClient>(collection);
                    _registeredClientService.Update(model);
                    return(RedirectToAction("Index"));
                }
                ModelState.AddModelError(string.Empty, GeneralMessages.DefectiveEntry);

                return(View(collection));
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
                {
                    ModelState.AddModelError(string.Empty, ex.Message);
                }
                else
                {
                    ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
                }
                return(View(collection));
            }
        }