Example #1
0
        // GET: LichTuan/Edit/5
        public ActionResult Edit(int id)
        {
            try
            {
                KeHoachCTBussinessService keHoachCTBussinessService = new KeHoachCTBussinessService();
                PhongBanBussinessService  phongBanBussinessService  = new PhongBanBussinessService();
                List <KeHoachCT>          listkeHoachCT             = keHoachCTBussinessService.GetKeHoachForUpdate(id);
                KeHoachCT keHoachCT = listkeHoachCT[0];
                //Get All User
                keHoachCT.ListPhongBan = phongBanBussinessService.GetAllNguoiDung();

                //Get List PhongBan
                keHoachCT.ListPhongBanDistinct = phongBanBussinessService.GetNguoiDungDistinct(keHoachCT.ListPhongBan);


                List <ThamDuModel> listThamDuModel = keHoachCTBussinessService.GetThamDuByIdKeHoach(id);
                //Get List KhachMoi
                //ThamDu : type =1
                keHoachCT.ListKhachMoiThamDu = keHoachCTBussinessService.GetKhachMoiByIdKeHoach(id) == null ?
                                               null : keHoachCTBussinessService.GetKhachMoiByIdKeHoach(id).FindAll(t => t.Kieu == 1);
                //ChuTri : type =2
                keHoachCT.ListKhachMoiChuTri = keHoachCTBussinessService.GetKhachMoiByIdKeHoach(id) == null ?
                                               null : keHoachCTBussinessService.GetKhachMoiByIdKeHoach(id).FindAll(t => t.Kieu == 2);

                //Check and fill selected for User in PhongBan
                //ThamDu : type =1
                keHoachCT.ListPhongBanThamDu = new List <PhongBan>();
                List <PhongBan> listPhongBanThamDuOld = keHoachCT.ListPhongBan;

                List <PhongBan> listPhongBanChuTriOld = ListExtensions.DeepCopy(listPhongBanThamDuOld);

                List <ThamDuModel> listKhachMoiModel = listThamDuModel.FindAll(t => t.Kieu == 1);
                keHoachCT.ListPhongBanThamDu = phongBanBussinessService.CheckSelectedThamDu(listPhongBanThamDuOld, listKhachMoiModel);
                //ChuTri : type =2
                keHoachCT.ListPhongBanChuTri = new List <PhongBan>();

                List <ThamDuModel> listChutriModel = listThamDuModel.FindAll(t => t.Kieu == 2);
                keHoachCT.ListPhongBanChuTri = phongBanBussinessService.CheckSelectedThamDu(listPhongBanChuTriOld, listChutriModel);

                //Get tuan le
                ViewBag.TuanLe = this.GetListWeekEdit(DateTimeExtensions.WeekOfYearISO8601(DateTime.ParseExact(keHoachCT.DenNgay, "dd/MM/yyyy", CultureInfo.InvariantCulture)));

                return(View(listkeHoachCT[0]));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        // GET: LichTuan/Create

        // GET: LichTuan/Edit/5
        public ActionResult Edit(int id)
        {
            try
            {
                KeHoachCTBussinessService keHoachCTBussinessService = new KeHoachCTBussinessService();
                PhongBanBussinessService  phongBanBussinessService  = new PhongBanBussinessService();
                List <KeHoachCT>          listkeHoachCT             = keHoachCTBussinessService.GetKeHoachForUpdate(id);
                KeHoachCT keHoachCT = listkeHoachCT[0];
                //Get All User
                keHoachCT.ListPhongBan = phongBanBussinessService.GetAllNguoiDung();

                //Get List PhongBan
                keHoachCT.ListPhongBanDistinct = phongBanBussinessService.GetNguoiDungDistinct(keHoachCT.ListPhongBan);


                List <ThamDuModel> listThamDuModel = keHoachCTBussinessService.GetThamDuByIdKeHoach(id);
                //Get List KhachMoi
                //ThamDu : type =1
                keHoachCT.ListKhachMoiThamDu = keHoachCTBussinessService.GetKhachMoiByIdKeHoach(id) == null ?
                                               null : keHoachCTBussinessService.GetKhachMoiByIdKeHoach(id).FindAll(t => t.Kieu == 1);
                //ChuTri : type =2
                keHoachCT.ListKhachMoiChuTri = keHoachCTBussinessService.GetKhachMoiByIdKeHoach(id) == null ?
                                               null : keHoachCTBussinessService.GetKhachMoiByIdKeHoach(id).FindAll(t => t.Kieu == 2);

                //Check and fill selected for User in PhongBan
                //ThamDu : type =1
                keHoachCT.ListPhongBanThamDu = new List <PhongBan>();
                List <PhongBan> listPhongBanThamDuOld = keHoachCT.ListPhongBan;

                List <PhongBan> listPhongBanChuTriOld = ListExtensions.DeepCopy(listPhongBanThamDuOld);

                List <ThamDuModel> listKhachMoiModel = listThamDuModel.FindAll(t => t.Kieu == 1);
                keHoachCT.ListPhongBanThamDu = phongBanBussinessService.CheckSelectedThamDu(listPhongBanThamDuOld, listKhachMoiModel);
                //ChuTri : type =2
                keHoachCT.ListPhongBanChuTri = new List <PhongBan>();

                List <ThamDuModel> listChutriModel = listThamDuModel.FindAll(t => t.Kieu == 2);
                keHoachCT.ListPhongBanChuTri = phongBanBussinessService.CheckSelectedThamDu(listPhongBanChuTriOld, listChutriModel);


                return(View(listkeHoachCT[0]));
            }
            catch
            {
                return(View());
            }
        }