public ActionResult ListAmount() { List<StoreManager> storeManagers = StoreManagerBUS.GetList(); List<StoreManagerBalanceSelect> lstObj = new List<StoreManagerBalanceSelect>(); foreach (StoreManager sm in storeManagers) { lstObj.Add(new StoreManagerBalanceSelect { ManagerName = sm.Name, ManagerPhone = sm.ManagerPhone, Id = sm.Id, Area = sm.City.Name, IdShop = sm.IdShop, Address = sm.Address, Balance = StoreManagerBUS.GetTotalLastMonthAmount(sm.Id), Selected = false }); } var model = new AdminListAmountViewModel { StoreManagers = lstObj }; model = SetAgents(model); return View(model); }
public ActionResult ListAmount(AdminListAmountViewModel obj) { /// Tạo danh sách Collect Number bool bSuccess = true; foreach(StoreManagerBalanceSelect sm in obj.StoreManagers) { if (sm.Selected == true && (StoreManagerBUS.GetTotalLastMonthAmount(sm.Id)>0)) { int iStatusId = CollectStateBUS.GetId("Processing"); CollectMoney existCollectMoney = CollectMoneyBUS.GetItem(sm.Id, iStatusId, DateTime.Today.Date); // Neu chua ton tai thi tao mới if (existCollectMoney == null) { bSuccess = bSuccess & CollectMoneyBUS.CreateNew(sm.Id, obj.AgentIdSelected); } // Neu da ton tai: Processing & ExpireDate > DateTime.Now // => Edit, update // Vì chỉ cho phép duy nhất 1 thành viên tạo else { bSuccess = bSuccess & CollectMoneyBUS.Update(existCollectMoney, obj.AgentIdSelected); } } } return RedirectToAction("CollectProcessing"); /// ------------------------------ //obj = SetAgents(obj); //List<StoreManager> storeManagers = StoreManagerBUS.GetList(); //List<StoreManagerBalanceSelect> lstObj = new List<StoreManagerBalanceSelect>(); //for (int i = 0; i < storeManagers.Count; i++) //{ // lstObj.Add(new StoreManagerBalanceSelect // { // Id = storeManagers[i].Id, // Area = storeManagers[i].City.Name, // IdShop = storeManagers[i].IdShop, // Address = storeManagers[i].Address, // Balance = StoreManagerBUS.GetTotalLastMonthAmount(storeManagers[i].Id), // // // Selected = obj.StoreManagers[i].Selected // }); //} //obj.StoreManagers = lstObj; //return View(obj); }
private AdminListAmountViewModel SetAgents(AdminListAmountViewModel obj) { List<Agent> agents = AgentBUS.GetList(); agents.Add(new Agent { Id = 0, Username = "******", FistName = "", LastName = "" }); obj.Agents = agents; return obj; }
public ActionResult ListAmount(AdminListAmountViewModel obj) { return View(); }