Пример #1
0
        public async Task <IActionResult> Post([FromBody] Area Area)
        {
            try
            {
                var result = await areaRepo.Insert(Area);

                return(StatusCode(201, result));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, new { message = ex.Message }));
            }
        }
Пример #2
0
 public ActionResult CreateOrUpdate(AreaFormViewModel viewModel) // model binding
 {
     viewModel.Area.Name = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(viewModel.Area.Name.ToLower());
     if (viewModel.Area.Id == 0) // Create
     {
         areaRepository.Insert(viewModel.Area);
         return(RedirectToAction("AreaList", "Area"));
     }
     else // Update
     {
         var area = areaRepository.Update(viewModel.Area);
         return(RedirectToAction("AreaList", "Area"));
     }
 }