public ActionResult ChangeCsmManPowers(DealerCsmModel dseReplaceModel)
 {
     ViewBag.List = Session["BreadcrumbList"];
     var rsm = _userService.GetUserByUserName(User.Identity.Name);
     var csms = _userService.FindUsers(dseReplaceModel.CsmIds, rsm.Id);
     var rsmCsms = new Dictionary<Csm, IEnumerable<CsmManPower>>();
     foreach (var csm in csms)
     {
         var csmManPowers = new List<CsmManPower>();
         var temp = new Csm();
         temp.CsmId = csm.Id;
         temp.CsmName = csm.Name;
         var csmDealers = csm.UserDealerMaps.Select(x => x.Dealer).Distinct();
         var manpowers = _dealerManpowerService.FindDealerManpowers(new List<int>{dseReplaceModel.DealerId}, csm.Id, string.Empty);
         foreach (var dealerManpower in manpowers)
         {
             var csmManPower = new CsmManPower();
             csmManPower.DseId = dealerManpower.Id;
             csmManPower.DseName = dealerManpower.Name;
             csmManPower.SapCode = dealerManpower.Profile.SAPCode;
             csmManPower.DseType = dealerManpower.Type;
             csmManPower.DealerName = csmDealers.Single(x => x.Id == dealerManpower.DealerId).Name;
             csmManPowers.Add(csmManPower);
         }
         rsmCsms.Add(temp, csmManPowers);
     }
     ViewBag.CsmId = rsm.Id;
     ViewBag.Role = "CSM";
     @ViewBag.UserName = rsm.Name;
     var model = new CsmManpowerReplaceModel();
     model.Csms = rsmCsms;
     return View(model);
 }
 public ActionResult ChooseDealer(DealerCsmModel dealerCsmModel)
 {
     var rsm = _userService.GetUserByUserName(User.Identity.Name);
     var csms = _userService.FindChilds(new List<int> { rsm.Id });
     var dealers = _userDealerMapServiceService.FindDealers(csms.Select(x => x.Id).Distinct().ToList());
     var dealerId = dealerCsmModel.DealerId;
     var maps=_userDealerMapServiceService.FindUserMapsByDealer(new List<int> {dealerId},x=>x.User).Where(x=>x.User.ParentId==rsm.Id);
     csms = maps.Select(x => x.User).ToList();
     dealerCsmModel.Csms = csms.ToDictionary(x => x.Id, x => x.Name);
     dealerCsmModel.Dealers = dealers.ToDictionary(x => x.Id, x => x.Name);
     return View(dealerCsmModel);
 }
 public ActionResult ChooseDealer()
 {
     Session["BreadcrumbList"] =
         Utils.HtmlExtensions.SetBreadcrumbs((List<BreadcrumbModel>)Session["BreadcrumbList"],
                                             string.Format("/Manpower/ChooseDealer"),
                                             "Transfer DSE/DSM");
     ViewBag.List = Session["BreadcrumbList"];
     var rsm = _userService.GetUserByUserName(User.Identity.Name);
     var csms = _userService.FindChilds(new List<int>{rsm.Id});
     var dealers = _userDealerMapServiceService.FindDealers(csms.Select(x => x.Id).Distinct().ToList());
     var dealerCsmModel = new DealerCsmModel();
     dealerCsmModel.Dealers = dealers.ToDictionary(x => x.Id, x => x.Name);
     ViewBag.CsmId = rsm.Id;
     ViewBag.Role = "RSM";
     @ViewBag.UserName = rsm.Name;
     return View(dealerCsmModel);
 }