示例#1
0
        public async System.Threading.Tasks.Task <ActionResult> Edit(int id)
        {
            var hopDongDOLABService = this.Service <IHopDongDOLABService>();
            var model = new HopDongDOLABEditViewModel(await hopDongDOLABService.GetAsync(id));

            if (model == null || !model.Active)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
示例#2
0
        public async System.Threading.Tasks.Task <ActionResult> Create(HopDongDOLABEditViewModel model)
        {
            var hopDongDOLABService = this.Service <IHopDongDOLABService>();
            var hopDongDOLABHocVienMappingService = this.Service <IHopDongDOLABHocVienMappingService>();

            try
            {
                var entity = model.ToEntity();
                entity.Active = true;
                await hopDongDOLABService.CreateAsync(entity);

                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                var    result         = await new SystemLogController().Create("Tạo hợp đồng", controllerName, entity.Id);
                var    idHopDongDOLAB = entity.Id;
                try
                {
                    foreach (var item in model.SelectedThongTinCaNhan)
                    {
                        var mapping = new HopDongDOLABHocVienMappingViewModel()
                        {
                            IdHopDongDOLAB   = idHopDongDOLAB,
                            IdThongTinCaNhan = item,
                        };
                        await hopDongDOLABHocVienMappingService.CreateAsync(mapping.ToEntity());
                    }
                    return(Json(new { success = true, message = "Tạo thành công" }));
                }
                catch (Exception e)
                {
                    await hopDongDOLABService.DeleteAsync(entity);

                    var listMapping = hopDongDOLABHocVienMappingService.GetByIdHopDongDOLAB(idHopDongDOLAB).ToList();
                    foreach (var item in listMapping)
                    {
                        await hopDongDOLABHocVienMappingService.DeleteAsync(item);
                    }
                    return(Json(new { success = false, message = Resource.ErrorMessage }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = Resource.ErrorMessage }));
            }
        }
示例#3
0
        public async System.Threading.Tasks.Task <JsonResult> Edit(HopDongDOLABEditViewModel model)
        {
            var hopDongDOLABService = this.Service <IHopDongDOLABService>();

            try
            {
                var entity = model.ToEntity();
                entity.Active = true;
                await hopDongDOLABService.UpdateAsync(entity);

                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                var    result         = await new SystemLogController().Create("Sửa hợp đồng", 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 }));
            }
        }
示例#4
0
        public ActionResult Create()
        {
            var model = new HopDongDOLABEditViewModel();

            return(View(model));
        }