public HttpResponseMessage Create(HttpRequestMessage request, HistoryActionViewModel historyActionVM)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var newHistoryAction = new HistoryAction();
                    newHistoryAction.UpdateHistoryAction(historyActionVM);
                    newHistoryAction.ActionDate = DateTime.Now;

                    _historyActionService.Add(newHistoryAction);
                    _historyActionService.Save();

                    var responseData = Mapper.Map <HistoryAction, HistoryActionViewModel>(newHistoryAction);
                    response = request.CreateResponse(HttpStatusCode.Created, responseData);
                }

                return response;
            }));
        }
Example #2
0
 public static void UpdateHistoryAction(this HistoryAction historyAction, HistoryActionViewModel historyActionVM)
 {
     historyAction.ID         = historyActionVM.ID;
     historyAction.UserName   = historyActionVM.UserName;
     historyAction.ActionName = historyActionVM.ActionName;
     historyAction.ActionDate = historyActionVM.ActionDate;
     historyAction.Status     = historyActionVM.Status;
 }