public ActionResult Add_ShopKefu(Shop _Shop, string[] ids) { if (ids != null && ids.Length > 0) { var listPinFen = this.pinFenRepo.GetAll() .Where(it => it._shop == _Shop); foreach (var PinFen in listPinFen) { //if (PinFen._user != _Shop.MainKfUser) //{ this.pinFenRepo.Delete(PinFen); //} } for (int i = 0; i < ids.Length; i++) { PinFen gd = new PinFen() { _user = new hkkf.Models.User { ID = ids[i].ToInt() }, _shop = _Shop, UpdateTime = DateTime.Now }; this.pinFenRepo.Save(gd); } //更新下能做店铺班组 return(Json(new { state = true, message = "添加或修改成功, 请刷新显示" })); } else { return(Json(new { state = false, message = "请选择店铺" })); } }
public ActionResult FenPei(string shopId, FormCollection form, string subAction) { Shop shop = shopRepository.GetByDatabaseID(Convert.ToInt32(shopId)); //查询此店铺是否之前分配过客服 if (pinFenRepository.IsFPShop(Convert.ToInt32(shopId))) { ViewBag.FenPeiList = pinFenRepository.FPShopList(Convert.ToInt32(shopId)); } ViewBag.UserList = userRepository.GetAll().Where(p => p.Type.ID == 1).ToList(); ViewBag.shopeName = shop.Name; ViewBag.shopeId = shop.ID; List <Kf_Role_Type> listKfRoleType = this.Kf_Role_TypeRepository.GetAll().ToList(); IEnumerable <SelectListItem> listRoleType = listKfRoleType.Select( p => new SelectListItem { Text = p.RoleName, Value = p.ID.ToString().Trim(), }); ViewData["kfRoleList"] = listRoleType; string mess = ""; string UserIDs = ""; string KfRoleIDs = ""; if (subAction == "save") { //清空该店铺所有的分配人员 var fplist = pinFenRepository.FPShopList(Convert.ToInt32(shopId)); if (fplist != null) { foreach (var fp in fplist) { pinFenRepository.Delete(fp); } } UserIDs = form["UserIDs"]; KfRoleIDs = form["KfRoleIDs"]; string[] UserID = UserIDs.Split(new char[] { ',' }); string[] KfRoleID = KfRoleIDs.Split(new char[] { ',' }); //如果USERID里面全是FALSE,则跳出,如果有一个是数字,则判断对应的角色是不是0,如果是0,则提示必须选择对应的熟悉分数或者排序。 for (int i = 0; i < UserID.Count(); i++) { if (UserID[i].ToString().Trim() == "false") { goto Last; } //如果判断 if (KfRoleID[i].ToString().Trim() == "0") { mess = "请选择人员的客服角色!"; return(RedirectToAction("FenPei", new { shopid = shopId, message = mess })); } PinFen pinFen = new PinFen(); pinFen._shop = shop; pinFen._user = this.userRepository.GetByDatabaseID(Convert.ToInt32(UserID[i])); pinFen.UpdateTime = System.DateTime.Today; this.pinFenRepository.SaveOrUpdate(pinFen); Last :; } } //string mess = "如果选择了人员,必须选择对应的熟悉分数或者排序!"; //return RedirectToAction("FenPei", new { shopid = shopId, message = mess }); return(RedirectToAction("FenPei", new { shopid = shopId, message = "sdfsdf" })); //try //{ // if (Sortypeid.IsNotNullAndEmpty() && Usertypeid.IsNotNullAndEmpty() && ScoreTypeid.IsNotNullAndEmpty()) // { // var stringUser = Usertypeid.Substring(1, Usertypeid.Length - 1); // var arrayUser = stringUser.Split(','); // int[] userids = Array.ConvertAll<string, int>(arrayUser, delegate(string s) { return int.Parse(s); }); // var stringSort = Sortypeid.Substring(1, Sortypeid.Length - 1); // var arraysort = stringSort.Split(','); // int[] sortids = Array.ConvertAll<string, int>(arraysort, delegate(string s) { return int.Parse(s); }); // var stringScore = ScoreTypeid.Substring(1, ScoreTypeid.Length - 1); // var arrayscore = stringScore.Split(','); // int[] scoreids = Array.ConvertAll<string, int>(arrayscore, delegate(string s) { return int.Parse(s); }); // if (userids.Count() == sortids.Count() && userids.Count() == scoreids.Count()) // { // for (int i = 0; i < userids.Length; i++) // { // if (pinFenRepository.IsExitByNameShopId(userids[i], shop.ID)) // { // ViewData["alertMessage"] = "选择的人员不能分配相同的店铺"; // return View("FenPei"); // } // PinFen _pinFen = new PinFen(); // _pinFen._shop = shop; // //_pinFen.Sort = sortids[i]; // //_pinFen.Score = scoreids[i]; // _pinFen._user = userRepository.GetByDatabaseID(userids[i]); // pinFenRepository.Save(_pinFen); // } // } // else // { // string mess = "如果选择了人员,必须选择对应的熟悉分数或者排序!"; // return RedirectToAction("FenPei", new { shopid = shopId, message = mess }); // } // } // else // { // string mess = "如果选择了人员,必须选择对应的熟悉分数或者排序!"; // return RedirectToAction("FenPei", new { shopid = shopId, message=mess }); // } // return RedirectToAction("ShopIndexForFenPei", "ShopManage", new { alertMessage = "分配成功!" }); //} //catch (RuleException ex) //{ // throw new RuleException(ex.Message, ex); //} }