public async Task <ActionResult> AddGuestBillInfo(string jsonObj) { try { var operatorProvider = OperatorProvider.Provider.GetCurrent(); GuestAccountingInfo obj = jsonObj.ToObject <GuestAccountingInfo>(); var result = await _accRepository.AddNewOrUpdateAccountingInfo(operatorProvider.ConnectToken, obj); if (result) { return(NewtonSoftJson(new JsonMessage <int, object> { Status = 1, Message = "已成功添加客人账务信息!" }, "text/html", JsonRequestBehavior.AllowGet, true)); } return(NewtonSoftJson(new JsonMessage <int, object> { Status = 0, Message = "新增账务信息失败" }, "text/html", JsonRequestBehavior.AllowGet, true)); } catch (Exception ex) { return(NewtonSoftJson(new JsonMessage <int, object> { Status = 0, Message = ex.Message }, "text/html", JsonRequestBehavior.AllowGet, true)); } }
public async Task <bool> AddNewOrUpdateAccountingInfo(string token, GuestAccountingInfo info) { using (var session = Factory.Create <ISession>(token)) { KrzwModel model = ConvertToModel(info); var result = await SaveOrUpdateAsync <ISession>(token, model); return(result > 0); } }
private KrzwModel ConvertToModel(GuestAccountingInfo info) { if (info == null) { return(null); } KrzwModel model = AutoMapper.Mapper.Map <GuestAccountingInfo, KrzwModel>(info); return(model); }
private GuestAccountingInfo ConvertToInfo(KrzwModel model) { if (model == null) { return(null); } GuestAccountingInfo info = AutoMapper.Mapper.Map <KrzwModel, GuestAccountingInfo>(model); return(info); }
private List <GuestAccountingInfo> ConvertToInfoList(IEnumerable <KrzwModel> sourceList) { if (sourceList == null) { return(null); } List <GuestAccountingInfo> list = new List <GuestAccountingInfo>(); foreach (KrzwModel model in sourceList) { //调用AutoMapper映射 GuestAccountingInfo customer = ConvertToInfo(model); list.Add(customer); } return(list); }