Exemplo n.º 1
0
        public async Task <IActionResult> PhanCong(int idHoiDong, int idMoDot, long[] idsDeTai)
        {
            var hoiDong = await _serviceHoiDong.GetById(idHoiDong);

            var XDDG = hoiDong.XetDuyetVaDanhGia.Where(x => x.Status == 1).ToList();

            for (int i = 0; i < XDDG.Count(); i++)
            {
                XDDG[i].IddeTaiNavigation.TinhTrangDeTai = (int)StatusDeTai.DaDangKy;
                if (Dot == 2)
                {
                    XDDG[i].IddeTaiNavigation.TinhTrangDeTai = (int)StatusDeTai.DanhGiaLai;
                }
                XDDG[i].IddeTaiNavigation.TinhTrangPhanCong = (int)StatusPhanCong.ChuaPhanCong;
                await _serviceXetDuyetDanhGia.Delete(XDDG[i]);
            }
            if (idsDeTai.Length == 0)
            {
                hoiDong.StatusPhanCong = 0; //chưa phân công
                await _serviceHoiDong.Update(hoiDong);

                return(Ok(new
                {
                    status = true,
                    mess = MessageResult.UpdateSuccess
                }));
            }
            for (int i = 0; i < idsDeTai.Length; i++)
            {
                var deTai = await _serviceDeTai.GetById(idsDeTai[i]);

                deTai.TinhTrangPhanCong = (int)StatusPhanCong.DaPhanCong;
                XetDuyetVaDanhGia entity = new XetDuyetVaDanhGia
                {
                    IddeTai = idsDeTai[i],
                    IdmoDot = idMoDot,
                };
                hoiDong.XetDuyetVaDanhGia.Add(entity);
            }
            hoiDong.StatusPhanCong = 1; //đã phân công
            await _serviceHoiDong.Update(hoiDong);

            return(Ok(new
            {
                status = true,
                mess = MessageResult.UpdateSuccess
            }));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> LapHD(LapHoiDongViewModel obj)
        {
            if (obj.Id > 0)
            {
                var hoiDong = await _serviceHoiDong.GetById(obj.Id);

                if (await EditHoiDong(obj, hoiDong))
                {
                    return(Ok(new
                    {
                        status = true,
                        mess = MessageResult.UpdateSuccess
                    }));
                }
                else
                {
                    return(Ok(new
                    {
                        status = false,
                        mess = MessageResult.Fail
                    }));
                }
            }
            else
            {
                HoiDong hoiDong = new HoiDong
                {
                    IdNguoiTao = long.Parse(User.Identity.Name),
                    TenHoiDong = obj.TenHoiDong,
                    NgayLap    = DateTime.Now
                };
                await _serviceHoiDong.Add(hoiDong);

                BoNhiemHD(obj, hoiDong);

                await _serviceHoiDong.Update(hoiDong);

                return(Ok(new
                {
                    status = true,
                    mess = MessageResult.CreateSuccess
                }));
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create(MoDot moDot)
        {
            var allXDDG = await _serviceXDDG.GetAll();

            if (allXDDG.Any())
            {
                foreach (var item in allXDDG)
                {
                    item.Status = 0;
                    await _serviceXDDG.Update(item);
                }
            }
            var HoiDong = await _serviceHoiDong.GetAll();

            if (HoiDong.Any())
            {
                foreach (var item in HoiDong)
                {
                    item.StatusPhanCong = (int)StatusPhanCong.ChuaPhanCong;
                    await _serviceHoiDong.Update(item);
                }
            }
            var DeTai = await _serviceDeTai.GetAll();

            if (DeTai.Any())
            {
                foreach (var item in DeTai)
                {
                    item.TinhTrangPhanCong = (int)StatusPhanCong.ChuaPhanCong;
                    await _serviceDeTai.Update(item);
                }
            }
            if (moDot.Loai == (int)MoDotLoai.DangKy)
            {
                var Nhom = await _serviceNhom.GetAll();

                if (Nhom.Any())
                {
                    foreach (var item in Nhom)
                    {
                        item.Status = (int)BaseStatus.Disable;
                        await _serviceNhom.Update(item);
                    }
                }
            }
            moDot.Status   = 1;
            moDot.IdquanLy = long.Parse(User.Identity.Name);
            await _service.Add(moDot);

            return(RedirectToAction("Index", new { mess = "Mở đợt thành công" }));
        }