Beispiel #1
0
        public ActionResult Add()
        {
            var init  = InitModel();
            var model = new AddCongViecViewModel
            {
                UsersInfos              = init.UsersInfos,
                LinhVucCongViecInfos    = init.LinhVucCongViecInfos,
                TrangThaiCongViecInfos  = init.TrangThaiCongViecInfos,
                VanBanLienQuanViewModel = new List <InitVanBanViewModel>
                {
                    new InitVanBanViewModel
                    {
                        CoQuanInfos = CoQuanRepository.GetAll().Select(x => x.ToDataInfo())
                    }
                },
                QuaTrinhXuLyViewModel = new List <InitQuaTrinhXuLyViewModel>
                {
                    new InitQuaTrinhXuLyViewModel
                    {
                        Gio       = 0,
                        Ngay      = new DateTime(),
                        NoiDung   = string.Empty,
                        NguoiThem = UserName
                    }
                },
                Guid = Guid.NewGuid().ToString()
            };

            return(View(model));
        }
Beispiel #2
0
        public JsonResult AddRecord(AddCongViecViewModel model)
        {
            return(ExecuteWithErrorHandling(() =>
            {
                var data = new HoSoCongViecResult
                {
                    CongViecPhoiHopResult = model.UsersPhoiHopId.Select(x => new CongViecPhoiHopResult {
                        UserId = x
                    }),
                    CongViecQuaTrinhXuLyResult =
                        model.QuaTrinhXuLyViewModel.Where(x => x.Gio != 0 && x.Phut != 0)
                        .Select(x => new CongViecQuaTrinhXuLyResult
                    {
                        GioBanHanh = (byte)x.Gio,
                        PhutBanHanh = (byte)x.Phut,
                        NgayBanHanh = x.Ngay,
                        NoiDung = x.NoiDung,
                        NguoiThem = x.NguoiThem,
                        NhacNho = (byte)x.NhacNho,
                        IsDeleted = false
                    }),
                    CongViecVanBanResults =
                        model.VanBanLienQuanViewModel.Where(
                            x => x.CoQuanId.HasValue && x.CoQuanId != 0 && !string.IsNullOrEmpty(x.NoiDung))
                        .Select(x => new CongViecVanBanResult
                    {
                        SoVanBan = x.SoVanBan,
                        NgayBanHanh = x.Ngay,
                        NoiDung = x.NoiDung,
                        CoQuanId = x.CoQuanId.Value
                    }),
                    NgayHetHan = model.NgayHetHan,
                    NgayTao = model.NgayKhoiTao,
                    LinhVucCongViecId = model.LinhVucCongViecId,
                    UserPhuTrachId = model.UserPhuTrachId,
                    UserXuLyId = model.UserXuLyChinhId,
                    TrangThaiCongViecId = model.TrangThaiCongViecId,
                    NoiDung = model.NoiDungCongViec,
                    CreatedBy = UserName
                };

                return ExecuteResult(() =>
                {
                    var saveResult = HoSoCongViecRepository.AddCongViecWithChildren(data);

                    if (data.Id > 0)
                    {
                        ExecuteTryLogException(() => { MoveFiles(model.Guid, data.Id); });
                    }
                    return saveResult;
                });
            }));
        }