/// <summary> /// 查询所有待审核入驻的申请 /// </summary> /// <returns></returns> public async Task <IActionResult> NoExamineForAllSettled() { var SettledCollection = await _ShopSelltedRepository.FindByAsyn(x => x.State == 0 && x.Step == 2); if (SettledCollection.Count() == 0) { ViewBag.SettledCollection = null; return(View("../../Views/Shop/ShopManager/NoExamineForAllSettled")); } var SettledVMCollection = new List <SK_WM_ShopSttledVM>(); foreach (var settled in SettledCollection) { var settledUser = _UserManager.Users.Where(x => x.Id == settled.BelongToUserID).FirstOrDefault(); settled.ShopForUser = settledUser; var SettledVM = new SK_WM_ShopSttledVM(settled); SettledVMCollection.Add(SettledVM); } ViewBag.SettledCollection = SettledCollection.Count(); return(View("../../Views/Shop/ShopManager/NoExamineForAllSettled", SettledVMCollection)); }
public async Task <IActionResult> Settled() { var username = User.Identity.Name; var user = await _UserManager.FindByNameAsync(username); if (user == null) { return(View("../../Views/Home/Logon")); } //bool isNew = false; var hasDuplicateNameShop = await _ShopSelltedRepository.HasInstanceAsyn(x => x.ShopForUser == user); var bo = _ShopSelltedRepository.GetAll().Where(x => x.ShopForUser == user).FirstOrDefault(); if (hasDuplicateNameShop) { bo.IsNew = false; } else { bo = new SK_WM_ShopSttled(); bo.IsNew = true; bo.Step = 0; } var boVM = new SK_WM_ShopSttledVM(bo); ViewBag.UserLogonInformation = GetUserName(); if (hasDuplicateNameShop) { return(View("../../Views/Shop/ShopManager/HasSettled", boVM)); } else { return(View("../../Views/Shop/ShopManager/Settled", boVM)); } }
public async Task <IActionResult> SaveSettled([Bind("ID,IsNew,Step,Name,Address,UserName,IDCar,MobilePhone,Telephone,LicenceID")] SK_WM_ShopSttledVM boVM) { var validateMessage = new ValidateMessage(); if (ModelState.IsValid) { var username = User.Identity.Name; var user = await _UserManager.FindByNameAsync(username); var hasDuplicateNameShop = await _ShopSelltedRepository.HasInstanceAsyn(x => x.Name == boVM.Name); if (hasDuplicateNameShop && boVM.IsNew) { validateMessage.IsOK = false; validateMessage.ValidateMessageItems.Add( new ValidateMessageItem() { IsPropertyName = false, MessageName = "Name", Message = "已经有店铺叫这个名了,换一个试试看吧" }); return(Json(validateMessage)); } var bo = new SK_WM_ShopSttled(); bo.ID = boVM.ID; if (!boVM.IsNew) { bo = await _ShopSelltedRepository.GetSingleAsyn(boVM.ID); } // 处理一般的属性数据 boVM.MapToShop(bo); var saveStatus = false; //处理上传文件 var serverPath = ""; long size = 0; var files = Request.Form.Files; var boImg = _ImageRepository.GetAll().Where(x => x.RelevanceObjectID == bo.ID); var FrontIDCarimg = boImg.Where(x => x.Description == "FrontIDCar").FirstOrDefault(); var backIDCarimg = boImg.Where(x => x.Description == "BackIDCar").FirstOrDefault(); var Environmentimg = boImg.Where(x => x.Description == "Environment").FirstOrDefault(); var Licenceimg = boImg.Where(x => x.Description == "Licence").FirstOrDefault(); var fName = files.Where(x => x.Name == "FrontIDCar").FirstOrDefault(); var bName = files.Where(x => x.Name == "BackIDCar").FirstOrDefault(); var eName = files.Where(x => x.Name == "Environment").FirstOrDefault(); var lName = files.Where(x => x.Name == "Environment").FirstOrDefault(); if (boVM.IsNew == false) { if (/*(backIDCarimg == null || FrontIDCarimg == null)&& */ (fName == null || bName == null) && boVM.Step == 1) { validateMessage.IsOK = false; validateMessage.ValidateMessageItems.Add( new ValidateMessageItem() { IsPropertyName = false, MessageName = "IdImg", Message = "请将身份信息补充完整再执行下一步" }); return(Json(validateMessage)); } if (/*(backIDCarimg != null || FrontIDCarimg != null)*//*&&(Environmentimg == null || Licenceimg == null) && */ (eName == null || lName == null) && (fName != null || bName != null) && boVM.Step == 2) { validateMessage.IsOK = false; validateMessage.ValidateMessageItems.Add( new ValidateMessageItem() { IsPropertyName = false, MessageName = "SettledImg", Message = "请将店铺信息补充完整再执行下一步" }); return(Json(validateMessage)); } } if (files.Count() > 0) { foreach (var file in files) { var fileName = ContentDispositionHeaderValue .Parse(file.ContentDisposition) .FileName .Trim('"') .Substring(files[0].FileName.LastIndexOf("\\") + 1); fileName = bo.ID + "_" + fileName; var boPath = "../../images/ShopSettledImg/" + fileName; fileName = _HostingEnv.WebRootPath + $@"\images\ShopSettledImg\{fileName}"; serverPath = fileName; size += file.Length; using (FileStream fs = System.IO.File.Create(fileName)) { file.CopyTo(fs); fs.Flush(); } var businessIamge = new BusinessImage() { DisplayName = bo.Name, RelevanceObjectID = bo.ID, UploadPath = boPath, Description = file.Name }; if (file.Name == "Licence") { bo.Licence = businessIamge; ViewBag.LiImg = businessIamge.UploadPath; } else if (file.Name == "Environment") { bo.Environment = businessIamge; ViewBag.EnIMg = businessIamge.UploadPath; } else if (file.Name == "BackIDCar") { if (backIDCarimg == null) { bo.BackIDCar = businessIamge; ViewBag.BaImg = businessIamge.UploadPath; } else { backIDCarimg.UploadPath = businessIamge.UploadPath; bo.BackIDCar = backIDCarimg; ViewBag.BaImg = backIDCarimg.UploadPath; } } else if (file.Name == "FrontIDCar") { if (FrontIDCarimg == null) { bo.FrontIDCar = businessIamge; ViewBag.FCimg = businessIamge.UploadPath; } else { FrontIDCarimg.UploadPath = businessIamge.UploadPath; bo.FrontIDCar = FrontIDCarimg; ViewBag.FCimg = FrontIDCarimg.UploadPath; } } } } bo.ShopForUser = user; bo.BelongToUserID = user.Id; saveStatus = await _ShopSelltedRepository.AddOrEditAndSaveAsyn(bo); if (saveStatus) { validateMessage.IsOK = true; validateMessage.ValidateMessageItems.Add( new ValidateMessageItem { IsPropertyName = false, MessageName = "Succeed", Message = "" }); return(Json(validateMessage)); } else { validateMessage.IsOK = false; validateMessage.ValidateMessageItems.Add( new ValidateMessageItem() { IsPropertyName = false, MessageName = "RemoteErr", Message = "数据保存异常" }); return(Json(validateMessage)); } } else { //return View("../../Views/BusinessOrganization/BusinessBG/CreateOrEdit", boVM); validateMessage.IsOK = false; var errCollection = from errKey in ModelState.Keys from errMessage in ModelState[errKey].Errors where ModelState[errKey].Errors.Count > 0 select(new { errKey, errMessage.ErrorMessage }); foreach (var errItem in errCollection) { var vmItem = new ValidateMessageItem() { IsPropertyName = true, MessageName = errItem.errKey, Message = errItem.ErrorMessage }; validateMessage.ValidateMessageItems.Add(vmItem); } return(Json(validateMessage)); } }