// // GET: /FMM/ReasonCode/Detail public async Task <ActionResult> Detail(string key) { using (ReasonCodeServiceClient client = new ReasonCodeServiceClient()) { MethodReturnResult <ReasonCode> result = await client.GetAsync(key); if (result.Code == 0) { ReasonCodeViewModel viewModel = new ReasonCodeViewModel() { Name = result.Data.Key, Type = result.Data.Type, Class = result.Data.Class, CreateTime = result.Data.CreateTime, Creator = result.Data.Creator, Description = result.Data.Description, Editor = result.Data.Editor, EditTime = result.Data.EditTime }; return(PartialView("_InfoPartial", viewModel)); } else { ModelState.AddModelError("", result.Message); } } return(PartialView("_InfoPartial")); }
public ActionResult PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize) { if (ModelState.IsValid) { int pageNo = currentPageNo ?? 0; int pageSize = currentPageSize ?? 20; if (Request["PageNo"] != null) { pageNo = Convert.ToInt32(Request["PageNo"]); } if (Request["PageSize"] != null) { pageSize = Convert.ToInt32(Request["PageSize"]); } using (ReasonCodeServiceClient client = new ReasonCodeServiceClient()) { PagingConfig cfg = new PagingConfig() { PageNo = pageNo, PageSize = pageSize, Where = where ?? string.Empty, OrderBy = orderBy ?? string.Empty }; MethodReturnResult <IList <ReasonCode> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } } } return(PartialView("_ListPartial")); }
public async Task <ActionResult> SaveModify(ReasonCodeViewModel model) { using (ReasonCodeServiceClient client = new ReasonCodeServiceClient()) { MethodReturnResult <ReasonCode> result = await client.GetAsync(model.Name); if (result.Code == 0) { result.Data.Class = model.Class; result.Data.Type = model.Type; result.Data.Description = model.Description; result.Data.Editor = User.Identity.Name; result.Data.EditTime = DateTime.Now; MethodReturnResult rst = await client.ModifyAsync(result.Data); if (rst.Code == 0) { rst.Message = string.Format(FMMResources.StringResource.ReasonCode_SaveModify_Success , model.Name); } return(Json(rst)); } return(Json(result)); } }
public async Task <ActionResult> Save(ReasonCodeViewModel model) { using (ReasonCodeServiceClient client = new ReasonCodeServiceClient()) { ReasonCode obj = new ReasonCode() { Key = model.Name, Type = model.Type, Class = model.Class, Status = EnumObjectStatus.Available, Description = model.Description, Editor = User.Identity.Name, EditTime = DateTime.Now, CreateTime = DateTime.Now, Creator = User.Identity.Name }; MethodReturnResult rst = await client.AddAsync(obj); if (rst.Code == 0) { rst.Message = string.Format(FMMResources.StringResource.ReasonCode_Save_Success , model.Name); } return(Json(rst)); } }
public async Task <ActionResult> Delete(string key) { MethodReturnResult result = new MethodReturnResult(); using (ReasonCodeServiceClient client = new ReasonCodeServiceClient()) { result = await client.DeleteAsync(key); if (result.Code == 0) { result.Message = string.Format(FMMResources.StringResource.ReasonCode_Delete_Success , key); } return(Json(result)); } }
// // GET: /FMM/ReasonCode/ public ActionResult Index() { using (ReasonCodeServiceClient client = new ReasonCodeServiceClient()) { PagingConfig cfg = new PagingConfig() { PageNo = 1, OrderBy = "Key" }; MethodReturnResult <IList <ReasonCode> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } } return(View(new ReasonCodeQueryViewModel())); }
public ActionResult Query(ReasonCodeQueryViewModel model) { if (ModelState.IsValid) { using (ReasonCodeServiceClient client = new ReasonCodeServiceClient()) { StringBuilder where = new StringBuilder(); if (model != null) { if (!string.IsNullOrEmpty(model.Name)) { where.AppendFormat(" {0} Key LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Name); } if (model.Type != null) { where.AppendFormat(" {0} Type = '{1}'" , where.Length > 0 ? "AND" : string.Empty , Convert.ToInt32(model.Type)); } } PagingConfig cfg = new PagingConfig() { OrderBy = "Key", Where = where.ToString() }; MethodReturnResult <IList <ReasonCode> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } } } return(PartialView("_ListPartial")); }
public IEnumerable <SelectListItem> GetReasonCodeName(EnumReasonCodeType type) { using (ReasonCodeServiceClient client = new ReasonCodeServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = string.Format("Type='{0}'", Convert.ToInt32(type)) }; MethodReturnResult <IList <ReasonCode> > result = client.Get(ref cfg); if (result.Code <= 0) { IEnumerable <SelectListItem> lst = from item in result.Data select new SelectListItem() { Text = item.Key, Value = item.Key }; return(lst); } } return(new List <SelectListItem>()); }