public ActionResult DeleteGoOutReason(DataSourceLoadOptions loadOptions, string values) { try { var deleteGoOutReason = new GoOutReasonViewModel(); JsonConvert.PopulateObject(values, deleteGoOutReason); DeleteGoOutReasonResult result = this.TransactionService.DeleteGoOutReason(deleteGoOutReason.GoOutID, UserDetail.UserID); return(Content(JsonConvert.SerializeObject(GetMsgFromDeleteActionResult(result)), ConstantValues.JSON_CONTENT_TYPE)); } catch (Exception ex) { throw ex; } }
public ActionResult InsertGoOutReason(string key, string values) { try { var newGoOutReason = new GoOutReasonViewModel(); JsonConvert.PopulateObject(values, newGoOutReason); //Combine Date and Time Label DateTime tmpStartTime = new DateTime(newGoOutReason.StartDate.Year, newGoOutReason.StartDate.Month, newGoOutReason.StartDate.Day , newGoOutReason.StartTime.Hour, newGoOutReason.StartTime.Minute, newGoOutReason.StartTime.Second); DateTime tmpEndTime = new DateTime(newGoOutReason.EndDate.Year, newGoOutReason.EndDate.Month, newGoOutReason.EndDate.Day , newGoOutReason.EndTime.Hour, newGoOutReason.EndTime.Minute, newGoOutReason.EndTime.Second); newGoOutReason.StartTime = tmpStartTime; newGoOutReason.EndTime = tmpEndTime; ValidateModel(newGoOutReason); if (!ModelState.IsValid) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, ModelState.ToString())); } SaveGoOutReasonResult result = new SaveGoOutReasonResult(); if (newGoOutReason.StartTime > newGoOutReason.EndTime) { result.ErrorType = ConstantValues.TypeWarning; result.ErrorMessage = String.Format(MessageListResource.W0001, "Date"); return(Content(JsonConvert.SerializeObject(result), ConstantValues.JSON_CONTENT_TYPE)); } newGoOutReason.UpdateBy = UserDetail.UserID; result = TransactionService.SaveGoOutReason(newGoOutReason.ToEntity(), ConstantValues.ADD); return(Content(JsonConvert.SerializeObject(GetMsgFromInsertUpdateActionResult(result)), ConstantValues.JSON_CONTENT_TYPE)); } catch (Exception ex) { throw ex; } }
//public static GoOutReasonViewModel ToModel(this GoOutReasonByID data) //{ // var entity = AutoMapper.Mapper.Map<GoOutReasonViewModel>(data); // entity.FullName = data.EmpCode; // return entity; //} public static GoOutReason ToEntity(this GoOutReasonViewModel model) { var entity = AutoMapper.Mapper.Map <GoOutReason>(model); return(entity); }