示例#1
0
        public ActionResult Create(int idThongTinCaNhan)
        {
            var model = new ThongTinGiaDinhEditViewModel();

            model.Relation = (Relation)(model.QuanHe != null ? model.QuanHe : 0);
            return(View(model));
        }
示例#2
0
        public async System.Threading.Tasks.Task <ActionResult> Edit(ThongTinGiaDinhEditViewModel model)
        {
            try
            {
                var thongTinGiaDinhService = this.Service <IThongTinGiaDinhService>();
                var entity = await thongTinGiaDinhService.GetAsync(model.Id);

                if (entity == null || entity.Active == false)
                {
                    return(Json(new { success = false, message = Resource.ErrorMessage }));
                }
                model.CopyToEntity(entity);
                entity.Active           = true;
                entity.QuanHe           = (int)model.Relation;
                entity.IdThongTinCaNhan = model.IdThongTinCaNhan;

                await thongTinGiaDinhService.UpdateAsync(entity);

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

                return(Json(new { success = true, message = "Sửa thành công!" }));
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = Resource.ErrorMessage }));
            }
        }
示例#3
0
        public async System.Threading.Tasks.Task <ActionResult> Edit(int id)
        {
            var thongTinGiaDinhService = this.Service <IThongTinGiaDinhService>();
            var model = new ThongTinGiaDinhEditViewModel(await thongTinGiaDinhService.GetAsync(id));

            if (model == null || model.Active == false)
            {
                return(Json(new { success = false, message = Resource.ErrorMessage }));
            }
            model.Relation = (Relation)model.QuanHe;
            return(View(model));
        }
示例#4
0
        public async System.Threading.Tasks.Task <JsonResult> Create(ThongTinGiaDinhEditViewModel model)
        {
            try
            {
                var thongTinGiaDinhService = this.Service <IThongTinGiaDinhService>();
                model.QuanHe = (int)model.Relation;
                model.Active = true;

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

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

                return(Json(new { success = true, message = "Tạo thành công" }));
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = Resource.ErrorMessage }));
            }
        }