예제 #1
0
        public async Task <ActionResult> Edit(ProcedureCategoryViewModel procedureCategoryViewModel)
        {
            if (ModelState.IsValid)
            {
                await _procedureCategoryService.Edit(procedureCategoryViewModel.MapToDto());

                return(RedirectToAction("Index"));
            }

            return(View(procedureCategoryViewModel));
        }
예제 #2
0
        public static ProcedureCategoryDto MapToDto(this ProcedureCategoryViewModel viewModel)
        {
            if (viewModel == null)
            {
                return(null);
            }

            return(new ProcedureCategoryDto
            {
                Id = viewModel.Id,
                Name = viewModel.Name,
                Description = viewModel.Description
            });
        }
예제 #3
0
        public ActionResult Create(ProcedureCategoryViewModel categoryViewModel)
        {
            ProcedureCategory category = null;

            if (ModelState.IsValid)
            {
                category = new ProcedureCategory()
                {
                    Name        = categoryViewModel.Name,
                    Description = categoryViewModel.Description
                };

                db.ProcedureCategories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(categoryViewModel));
        }
예제 #4
0
        public ActionResult Edit(ProcedureCategoryViewModel categoryViewModel)
        {
            ProcedureCategory category = null;

            if (ModelState.IsValid)
            {
                category = new ProcedureCategory()
                {
                    Id          = category.Id,
                    Name        = category.Name,
                    Description = category.Description
                };

                db.Entry(category).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(categoryViewModel));
        }
예제 #5
0
        // GET: Categories/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProcedureCategory category = db.ProcedureCategories.Find(id);

            if (category == null)
            {
                return(NotFound());
            }
            ProcedureCategoryViewModel viewModel = new ProcedureCategoryViewModel()
            {
                Id          = category.Id,
                Name        = category.Name,
                Description = category.Description
            };

            return(View(viewModel));
        }
예제 #6
0
        // GET: Category/Create
        public ActionResult Create()
        {
            ProcedureCategoryViewModel viewModel = new ProcedureCategoryViewModel();

            return(View(viewModel));
        }