public JsonResult AddStores(Stores storesModel) { //var stores = strStores.FromJson<Stores>(); IStoresService storesService = ServiceFactory.Create <IStoresService>(); bool flage = storesService.Exists(t => t.ShopId == storesModel.ShopId && t.StoreName == storesModel.StoreName); if (flage) { return(Json(new Result(false, "已经存在同名门店请修改"), JsonRequestBehavior.AllowGet)); } if (!string.IsNullOrWhiteSpace(storesModel.StoresImage)) { storesModel.StoresImage = FileHelper.Move(storesModel.StoresImage, "/Upload/Reality/" + CurrentInfo.CurrentStore.ID + "/storeImage/"); } if (!string.IsNullOrWhiteSpace(storesModel.ReceiptLogo)) { string newRoute = ServiceHelper.GetCommonService.ThumbnailImage(storesModel.ReceiptLogo, CurrentInfo.CurrentStore.ID, 128, 128, "CUT", "ReceiptLogo"); storesModel.ReceiptLogo = newRoute; } if (storesModel.LongitudeX == "NaN") { storesModel.LongitudeX = "0"; } if (storesModel.LatitudeY == "NaN") { storesModel.LatitudeY = "0"; } var data = storesService.AddEntity(storesModel); return(Json(new Result(data != null, ResultType.Add), JsonRequestBehavior.AllowGet)); }
public JsonResult EditStores(Stores storesModel) { //var stores = strStores.FromJson<Stores>(); IStoresService storesService = ServiceFactory.Create <IStoresService>(); var dbData = storesService.GetEntity(storesModel.ID, false); bool flage = storesService.Exists(t => t.ID != storesModel.ID && t.ShopId == storesModel.ShopId && t.StoreName == storesModel.StoreName); if (flage) { return(Json(new Result(false, "已经存在同名门店请修改"), JsonRequestBehavior.AllowGet)); } //如果用户有传文件,并且文件和数据库中保存的不一样,则需要保存,如果和数据库中一致,无需保存 if (!string.IsNullOrWhiteSpace(storesModel.StoresImage) && storesModel.StoresImage != dbData.StoresImage) { storesModel.StoresImage = FileHelper.Move(storesModel.StoresImage, "/Upload/Reality/" + CurrentInfo.CurrentStore.ID + "/storeImage/"); } if (!string.IsNullOrWhiteSpace(storesModel.ReceiptLogo) && storesModel.ReceiptLogo != dbData.ReceiptLogo) { string newRoute = ServiceHelper.GetCommonService.ThumbnailImage(storesModel.ReceiptLogo, CurrentInfo.CurrentStore.ID, 128, 128, "CUT", "ReceiptLogo"); storesModel.ReceiptLogo = newRoute; } if (storesModel.LongitudeX == "NaN") { storesModel.LongitudeX = "0"; } if (storesModel.LatitudeY == "NaN") { storesModel.LatitudeY = "0"; } dbData.StoreName = storesModel.StoreName; dbData.Phone = storesModel.Phone; dbData.Adress = storesModel.Adress; dbData.LatitudeY = storesModel.LatitudeY; dbData.LongitudeX = storesModel.LongitudeX; dbData.BankName = storesModel.BankName; dbData.BankCard = storesModel.BankCard; dbData.IsMainStore = storesModel.IsMainStore; dbData.IsShare = storesModel.IsShare; dbData.IsShowWeiXin = storesModel.IsShowWeiXin; dbData.StoresImage = storesModel.StoresImage; dbData.PrintRemark = storesModel.PrintRemark; dbData.Disabled = storesModel.Disabled; bool isSuccess = dbData.Update(); return(Json(new Result(isSuccess, ResultType.Update), JsonRequestBehavior.AllowGet)); }
/// <summary> /// 门店商家管理页面 /// </summary> /// <returns></returns> public ActionResult CustStoreManage() { IShopsService shopsService = ServiceFactory.Create <IShopsService>(); IStoresService storesService = ServiceFactory.Create <IStoresService>(); //判断当前用户是否是这个商家的管理员,如果不是则拒绝访问 //var shop = shopsService.GetFirstOrDefault(t => t); //bool isIntention = CurrentInfo.CurrentUser.IsIntention == null ? false : Convert.ToBoolean(CurrentInfo.CurrentUser.IsIntention); //if (!CurrentInfo.IsShopAdmin && !isIntention) //{ // return RedirectToAction("Error403", "Home", new { area = "Admin" }); //} //判断是否已经设置过主店,如果设置了,则不允许用户再次修改 var hasMainStore = storesService.Exists(t => t.ShopId == CurrentInfo.CurrentUser.ShopsID && t.IsMainStore == true); ViewBag.HasMainStore = hasMainStore; return(View()); }