public IActionResult Edit(int id, [FromBody] StructureDetailsVM model)
 {
     if (ModelState.IsValid)
     {
         string user = User.Identity.Name;
         model.Id = id;
         int newStructureId = _structureService.EditStructure(model, user);
         return(CreatedAtAction(nameof(GetDetails), new { id = newStructureId }, model));
     }
     return(BadRequest());
 }
Exemple #2
0
        public IActionResult EditStructure(StructureDetailsVM model)
        {
            int structureId = 0;

            if (ModelState.IsValid)
            {
                if (model.Id == 0)
                {
                    structureId = _structureService.AddStructure(model, User.Identity.Name);
                }
                else
                {
                    structureId = _structureService.EditStructure(model, User.Identity.Name);
                }
                return(RedirectToAction("StructureDetails", new { id = structureId }));
            }
            return(View(model));
        }