예제 #1
0
        public async Task <ActionResult> Create(ThongTinCaNhanEditViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(View(model));
            }
            try
            {
                var thongTinCaNhanService = this.Service <IThongTinCaNhanService>();
                model.Active           = true;
                model.GioiTinh         = (int)model.Gender;
                model.TrinhDoVanHoa    = (int)model.EducationLevel;
                model.TinhTrangGiaDinh = (int)model.FamilyStatus;

                var entity = model.ToEntity();
                await thongTinCaNhanService.CreateAsync(entity);

                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                var    result         = await new SystemLogController().Create("Tạo", controllerName, entity.Id);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult Create()
        {
            var trungTamGTVLService = this.Service <ITrungTamGTVLService>();
            var model = new ThongTinCaNhanEditViewModel();

            model.Gender           = (Gender)1;
            model.FamilyStatus     = (FamilyStatus)model.TinhTrangGiaDinh;
            model.EducationLevel   = (EducationLevel)(model.TrinhDoVanHoa != null ? model.TrinhDoVanHoa : 0);
            model.AvailableMaNguon = trungTamGTVLService.GetActive().Select(q => new SelectListItem()
            {
                Text     = q.TenCoSo,
                Value    = q.Id.ToString(),
                Selected = false,
            });
            return(View(model));
        }
예제 #3
0
        public async Task <ActionResult> Edit(int id)
        {
            var thongTinCaNhanService = this.Service <IThongTinCaNhanService>();
            var trungTamGTVLService   = this.Service <ITrungTamGTVLService>();
            var model = new ThongTinCaNhanEditViewModel(await thongTinCaNhanService.GetAsync(id));

            model.Gender           = (Gender)model.GioiTinh;
            model.FamilyStatus     = (FamilyStatus)model.TinhTrangGiaDinh;
            model.EducationLevel   = (EducationLevel)(model.TrinhDoVanHoa != null ? model.TrinhDoVanHoa : 0);
            model.AvailableMaNguon = trungTamGTVLService.GetActive().Select(q => new SelectListItem()
            {
                Text     = q.TenCoSo,
                Value    = q.Id.ToString(),
                Selected = (q.Id == model.IdTrungTamGTVL),
            });
            return(View(model));
        }
예제 #4
0
        public async Task <ActionResult> Edit(ThongTinCaNhanEditViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(View(model));
            }
            var thongTinCaNhanService = this.Service <IThongTinCaNhanService>();
            var entity = await thongTinCaNhanService.GetAsync(model.Id);

            model.CopyToEntity(entity);
            entity.Active           = true;
            entity.GioiTinh         = (int)model.Gender;
            entity.TrinhDoVanHoa    = (int)model.EducationLevel;
            entity.TinhTrangGiaDinh = (int)model.FamilyStatus;

            await thongTinCaNhanService.UpdateAsync(entity);

            string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            var    result         = await new SystemLogController().Create("Sửa", controllerName, entity.Id);

            return(RedirectToAction("Index"));
        }