public ActionResult Setup(ComponentTypeSetupViewModel vm)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (vm.Id > 0)
                    {
                        if (_componentTypeService.UpdateComponentType(vm))
                        {
                            SystemMessages.Add(ComponentStrings.ComponentType_Edit_Update_Success_Msg, false, true);
                        }
                        else
                        {
                            SystemMessages.Add(CommonStrings.No_Record, true, true);
                        }
                    }
                    else
                    {
                        _componentTypeService.CreateComponentType(vm);
                        SystemMessages.Add(ComponentStrings.ComponentType_Edit_Create_Success_Msg, false, true);
                    }

                    return(new XHR_JSON_Redirect());
                }
                catch (Exception ex)
                {
                    SystemMessages.Add(CommonStrings.Server_Error, true, true);
                }
            }

            return(PartialView("_Setup", vm));
        }
Esempio n. 2
0
 public IActionResult UpdateComponentType(ComponentTypeDetails componentType, int id)
 {
     try {
         var response = _componentTypeService.UpdateComponentType(componentType, id);
         return(Ok(new { message = response.Message, code = 204 }));
     } catch (ValueNotFoundException e) {
         Util.LogError(e);
         return(StatusCode(StatusCodes.Status422UnprocessableEntity, new ErrorClass()
         {
             code = StatusCodes.Status422UnprocessableEntity.ToString(), message = e.Message
         }));
     } catch (Exception e) {
         Util.LogError(e);
         return(StatusCode(StatusCodes.Status500InternalServerError, new ErrorClass()
         {
             code = StatusCodes.Status500InternalServerError.ToString(), message = "Something went wrong"
         }));
     }
 }
Esempio n. 3
0
 public ActionResult Edit(ComponentTypeModel componentTypeModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _ComponentTypeService.UpdateComponentType(componentTypeModel);
             TempData["Message"]     = "Component Type updated successfully.";
             TempData["MessageType"] = (int)AlertMessageTypes.Success;
             return(RedirectToAction("List"));
         }
         else
         {
             return(View(componentTypeModel));
         }
     }
     catch (Exception e)
     {
         _logger.Error(e);
         TempData["Message"]     = "Internal server error. Component Type not updated. Please contact administrator.";
         TempData["MessageType"] = (int)AlertMessageTypes.Danger;
         return(View(componentTypeModel));
     }
 }