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));
        }
        public ActionResult Setup(int?id)
        {
            ComponentTypeSetupViewModel vm = null;

            if (!id.HasValue)
            {
                ViewBag.Title = ComponentStrings.ComponentType_Create_Title;
                vm            = new ComponentTypeSetupViewModel()
                {
                    IsActive = true
                };
            }
            else
            {
                ViewBag.Title = ComponentStrings.ComponentType_Edit_Title;
                vm            = _componentTypeService.GetComponentTypeById(id.Value);
            }

            if (vm == null)
            {
                SystemMessages.Add(CommonStrings.No_Record, true, true);
                return(RedirectToAction("Index"));
            }

            return(PartialView("_Setup", vm));
        }
        public void CreateComponentType(ComponentTypeSetupViewModel vm)
        {
            ComponentType componentType = new ComponentType
            {
            };

            _uow.ComponentTypeRepository.Insert(componentType);
            _uow.Save();
        }
        public bool UpdateComponentType(ComponentTypeSetupViewModel vm)
        {
            ComponentType model = GetComponentType(vm.Id);

            if (model == null)
            {
                return(false);
            }

            model.IsActive    = vm.IsActive;
            model.NoOfMaxLoan = vm.NoOfMaxLoan;
            model.UserId      = _userHelper.Get().UserId;
            model.SystemDate  = _userHelper.Get().DayOpenClose.SystemDate;
            model.SetDate     = DateTime.Now;

            _uow.ComponentTypeRepository.Update(model);
            _uow.Save();

            return(true);
        }