Beispiel #1
0
        public ActionResult Create()
        {
            var nghiepDoanService = this.Service <INghiepDoanService>();
            var model             = new CongTyTiepNhanEditViewModel();

            model.AvailableNghiepDoan = nghiepDoanService.GetActive().Select(q => new SelectListItem()
            {
                Text     = q.TenNghiepDoan,
                Value    = q.Id.ToString(),
                Selected = false,
            });
            return(View(model));
        }
Beispiel #2
0
        public async System.Threading.Tasks.Task <ActionResult> Edit(int id)
        {
            var congTyTiepNhanService = this.Service <ICongTyTiepNhanService>();
            var nghiepDoanService     = this.Service <INghiepDoanService>();
            var model = new CongTyTiepNhanEditViewModel(await congTyTiepNhanService.GetAsync(id));

            if (model == null || model.Active == false)
            {
                return(Json(new { success = false, message = Resource.ErrorMessage }));
            }
            model.AvailableNghiepDoan = nghiepDoanService.GetActive().Select(q => new SelectListItem()
            {
                Text     = q.TenNghiepDoan,
                Value    = q.Id.ToString(),
                Selected = q.Id == model.idNghiepDoan,
            });
            return(View(model));
        }
Beispiel #3
0
        public async System.Threading.Tasks.Task <ActionResult> Edit(CongTyTiepNhanEditViewModel model)
        {
            try
            {
                var congTyTiepNhanService = this.Service <ICongTyTiepNhanService>();
                var entity = await congTyTiepNhanService.GetAsync(model.Id);

                model.CopyToEntity(entity);
                entity.Active = true;
                await congTyTiepNhanService.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 }));
            }
        }
Beispiel #4
0
        public async System.Threading.Tasks.Task <ActionResult> Create(CongTyTiepNhanEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            try
            {
                var congTyTiepNhanService = this.Service <ICongTyTiepNhanService>();
                model.Active = true;
                var entity = model.ToEntity();
                await congTyTiepNhanService.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)
            {
                return(Json(new { success = false, message = Resource.ErrorMessage }));
            }
        }