Example #1
0
        public async Task <ActionResult> Edit(ThongTinVeNuocEditViewModel model)
        {
            try
            {
                var thongTinVeNuocService = this.Service <IThongTinVeNuocService>();
                var entity = await thongTinVeNuocService.GetAsync(model.Id);

                if (entity == null || entity.Active == false)
                {
                    return(Json(new { success = false, message = Resource.ErrorMessage }));
                }
                model.CopyToEntity(entity);
                entity.Active           = true;
                entity.ThanhLyHopDong   = (int)model.ThanhLy == 1 ? true : false;
                entity.IdThongTinCaNhan = model.IdThongTinCaNhan;

                await thongTinVeNuocService.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 }));
            }
        }
Example #2
0
        public ActionResult Create(int idThongTinCaNhan)
        {
            var model = new ThongTinVeNuocEditViewModel();

            model.ThanhLy = (ThanhLyHopDong)(model.ThanhLyHopDong == true ? 1 : 0);
            return(View(model));
        }
Example #3
0
        public async Task <ActionResult> Detail(int id)
        {
            var thongTinVeNuocService = this.Service <IThongTinVeNuocService>();
            var model = new ThongTinVeNuocEditViewModel(await thongTinVeNuocService.GetAsync(id));

            if (model == null || model.Active == false)
            {
                return(Json(new { success = false, message = Resource.ErrorMessage }));
            }
            model.ThanhLy = (ThanhLyHopDong)(model.ThanhLyHopDong == true ? 1 : 0);
            return(View(model));
        }
Example #4
0
        public async Task <JsonResult> Create(ThongTinVeNuocEditViewModel model)
        {
            try
            {
                var thongTinVeNuocService = this.Service <IThongTinVeNuocService>();
                model.ThanhLyHopDong = (int)model.ThanhLy == 1 ? true : false;
                model.Active         = true;

                var entity = model.ToEntity();
                await thongTinVeNuocService.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 }));
            }
        }