public ActionResult Edit(FormCollection formCollection, [FetchBill(KeyName = "billid")]BillEntity model, BillViewModel vo) { var jsonResult = new JsonResult { ContentEncoding = Encoding.UTF8 }; var result = new ExecuteResult<int>(); if (ModelState.IsValid) { var tmp = Mapper.Map<BillViewModel, BillEntity>(vo); tmp.UpdatedDate = DateTime.Now; tmp.UpdatedUser = CurrentUser.CustomerId; tmp.Status = model.Status; tmp.CreatedDate = model.CreatedDate; tmp.CreatedUser = model.CreatedUser; tmp.Status = model.Status; tmp.IsDeleted = model.IsDeleted; Mapper.Map(tmp, model); Update(model); } else { result.StatusCode = StatusCode.ClientError; result.Message = "参数验证错误"; } jsonResult.Data = result; return jsonResult; }
public ActionResult Create(FormCollection formCollection, BillViewModel vo) { var jsonResult = new JsonResult { ContentEncoding = Encoding.UTF8 }; var result = new ExecuteResult<int>(); if (ModelState.IsValid) { var billEntity = Mapper.Map<BillViewModel, BillEntity>(vo); billEntity.CreatedDate = DateTime.Now; billEntity.CreatedUser = CurrentUser.CustomerId; billEntity.UpdatedDate = DateTime.Now; billEntity.UpdatedUser = CurrentUser.CustomerId; billEntity.Status = (int)DataStatus.Normal; var entity = Insert(billEntity); result.Data = entity.Id; } else { result.StatusCode = StatusCode.ClientError; } jsonResult.Data = result; return jsonResult; }