예제 #1
0
 public HttpResponseMessage Update(Identity id, TopicPut topic)
 {
     //todo id?mmm
     return(ProcessPut(() =>
     {
         var instance = topic.ToModel();
         updateGroupCommand.Execute(instance);
     }));
 }
예제 #2
0
        public ActionResult Edit(EditTopicModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var entity = entityById.Get <Topic>((Identity)model.TopicId);

            ModelToEntity(model, entity);
            updateTopicCommand.Execute(entity);
            return(RedirectToAction("Index"));
        }
예제 #3
0
 public IActionResult Put(int id, [FromQuery] TopicDto dto)
 {
     try
     {
         _updateCommand.Execute(dto);
         return(NoContent());
     }
     catch (EntityNotFoundException)
     {
         return(NotFound());
     }
     catch (Exception)
     {
         return(StatusCode(500, "An error has occured"));
     }
 }
예제 #4
0
        public ActionResult Edit(int id, TopicDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(View(dto));
            }

            try
            {
                _editCommand.Execute(dto);
                return(RedirectToAction(nameof(Index)));
            }
            catch (EntityNotFoundException)
            {
                TempData["error"] = "This Topic doesnt exist";
                return(RedirectToAction(nameof(Index)));
            }
            catch (EntityAlreadyExistsException)
            {
                TempData["error"] = "Topic already exists";
                return(View(dto));
            }
        }