/// <summary> /// 检查 entity 为 null的情况 /// </summary> /// <param name="source"></param> /// <returns></returns> private PointHistoryEntity PointHistoryEntityCheck(PointHistoryEntity source) { source.Description = source.Description ?? String.Empty; source.Name = source.Name ?? String.Empty; return(source); }
public JsonResult Delete([FetchPoint(KeyName = "id")] PointHistoryEntity entity) { if (entity == null) { return(FailResponse()); } using (var ts = new TransactionScope()) { if (entity.Amount > 0) { _userService.SubPoint(entity.User_Id, (int)entity.Amount, base.CurrentUser.CustomerId); } else { _userService.AddPoint(entity.User_Id, (int)entity.Amount, base.CurrentUser.CustomerId); } entity.UpdatedDate = DateTime.Now; entity.UpdatedUser = CurrentUser.CustomerId; entity.Status = (int)DataStatus.Deleted; _pointRepository.Delete(entity); ts.Complete(); } return(SuccessResponse()); }
public PointViewModel PointViewMapping(PointHistoryEntity source) { if (source == null) { return(null); } var target = Mapper.Map <PointHistoryEntity, PointViewModel>(source); return(target); }
public ActionResult Details(int?id, [FetchPoint(KeyName = "id")] PointHistoryEntity entity) { if (id == null || entity == null) { ModelState.AddModelError("", "参数验证失败."); return(View()); } var vo = MappingManager.PointViewMapping(entity); return(View(vo)); }
/// <summary> /// 添加一条积分 /// </summary> /// <param name="entity"></param> /// <returns></returns> public PointHistoryEntity Insert(PointHistoryEntity entity) { if (entity == null) { return(null); } entity.Name = entity.Name ?? String.Empty; entity.Description = entity.Description ?? String.Empty; try { return(_pointRepository.Insert(entity)); } catch (Exception ex) { Logger.Warn(String.Format("创建积分失败userid={0},type={1},sourceType={2},Amount={3}", entity.User_Id, entity.Type, entity.PointSourceType, entity.Amount)); Logger.Error(ex); return(null); } }
public PointHistoryEntity PointHistoryEntityMapping(PointHistoryEntity source, PointHistoryEntity target) { var result = Mapper.Map(source, target); return(PointHistoryEntityCheck(result)); }