public static void UpdateSyncLog(this SyncLog syncLog, SyncLogViewModel syncLogViewModel)
 {
     syncLog.ID          = syncLogViewModel.ID;
     syncLog.Quantity    = syncLogViewModel.Quantity;
     syncLog.LastTime    = syncLogViewModel.LastTime;
     syncLog.CreatedDate = syncLogViewModel.CreatedDate;
 }
Exemple #2
0
        public HttpResponseMessage Create(HttpRequestMessage request, SyncLogViewModel syncLogViewModel)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var newSyncLog = new SyncLog();
                    newSyncLog.UpdateSyncLog(syncLogViewModel);
                    newSyncLog.CreatedDate = DateTime.Now;
                    _syncLogService.Add(newSyncLog);
                    _syncLogService.Save();

                    var responseData = Mapper.Map <SyncLog, SyncLogViewModel>(newSyncLog);
                    response = request.CreateResponse(HttpStatusCode.Created, responseData);
                }

                return response;
            }));
        }