Пример #1
0
        public ActionResult Create()
        {
            var model = new SucKhoeEditViewModel();

            PrepareEdit(model);
            return(this.View(model));
        }
Пример #2
0
        public void PrepareEdit(SucKhoeEditViewModel model)
        {
            //thong tin ca nhan service
            var TTCNSerice = this.Service <IThongTinCaNhanService>();

            model.AvailableIDs = TTCNSerice.Get()
                                 .Where(q => q.Active == true)
                                 .Select(q => new SelectListItem()
            {
                Selected = false,
                Text     = q.HoTen,
                Value    = q.Id.ToString(),
            });
        }
Пример #3
0
        public async Task <ActionResult> Create(SucKhoeEditViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            var service = this.Service <ISucKhoeService>();

            try
            {
                var entity = model.ToEntity();
                await service.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(this.RedirectToAction("Index"));
        }
Пример #4
0
        public async Task <JsonResult> Edit(SucKhoeEditViewModel model)
        {
            var service = this.Service <ISucKhoeService>();

            if (!this.ModelState.IsValid)
            {
                return(Json(new { success = false, message = "Có lỗi xảy ra, vui lòng kiểm tra lại." }));
            }

            try
            {
                var entity = model.ToEntity();
                await service.UpdateAsync(entity);

                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                var    result         = await new SystemLogController().Create("Sửa", controllerName, entity.Id);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(Json(new { success = false, message = "Có lỗi xảy ra, vui lòng thử lại." }));
            }
            return(Json(new { success = true, message = "Cập nhật thành công." }));
        }