コード例 #1
0
        public ActionResult Add()
        {
            List <InitCoQuanCoLienQuan> coquanInfos = new List <InitCoQuanCoLienQuan>();

            NhomCoQuanRepository.GetAllWithChildren().ToList().ForEach(x =>
            {
                coquanInfos.Add(new InitCoQuanCoLienQuan
                {
                    NhomCoQuan  = x.ToDataInfo(),
                    CoQuanInfos = x.CoQuanResult.Select(s => s.ToDataInfo()).ToList()
                });
            });

            var linhVucs = LinhVucTacNghiepRepository.GetAll().Select(x => x.ToDataInfo());

            var model = new AddTacNghiepViewModel
            {
                Guid          = Guid.NewGuid().ToString(),
                NgayTao       = DateTime.Now,
                NgayHetHan    = DateTime.Now,
                NgayHoanThanh = DateTime.Now,
                CoQuanInfos   = coquanInfos,
                LinhVucInfos  = linhVucs,
            };

            return(View(model));
        }
コード例 #2
0
ファイル: HelpExtension.cs プロジェクト: dinhnv86/TechOffice
 public static TacNghiepResult ToTacNghiepResult(this AddTacNghiepViewModel entity)
 {
     return(new TacNghiepResult
     {
         LinhVucTacNghiepId = entity.LinhVucId,
         NgayHetHan = entity.NgayHetHan,
         NgayHoanThanh = entity.NgayHoanThanh,
         NgayTao = entity.NgayTao,
         NoiDung = entity.NoiDung,
         NoiDungTraoDoi = entity.NoiDungYKienTraoDoi,
         CoQuanInfos =
             entity.CoQuanInfos.Select(x => x.CoQuanInfos.Where(y => y.IsSelected))
             .Aggregate((a, b) => { return a.Concat(b); })
     });
 }
コード例 #3
0
        public JsonResult AddRecord(AddTacNghiepViewModel model)
        {
            return(ExecuteWithErrorHandling(() =>
            {
                var entity = model.ToTacNghiepResult().Update(x =>
                {
                    x.CreatedBy = UserName;
                    x.MucDoHoanThanhId = (int)EnumMucDoHoanThanh.CHUATHUHIEN;
                });
                return ExecuteResult(() =>
                {
                    var saveResult = TacNghiepRepository.AddTacNghiepWithTinhHinhThucHien(entity);

                    if (entity.Id > 0)
                    {
                        MoveFilesTacNghiep(model.Guid, entity.Id);
                    }

                    return saveResult;
                });
            }));
        }