Пример #1
0
        public ActionResult Save(RightViewModel rightViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //add
                    if (rightViewModel.RightId == 0 && rightViewModel.ActionName == "Add")
                    {
                        var model = new TblRight()
                        {
                            RightId       = rightViewModel.RightId,
                            RightName     = rightViewModel.RightName,
                            RightTitle    = rightViewModel.RightTitle,
                            Description   = rightViewModel.Description,
                            ApplicationId = rightViewModel.ApplicationId,
                            ModuleId      = rightViewModel.ModuleId
                        };

                        _rightRepository.Insert(model);
                    }
                    else if (rightViewModel.ActionName == "Edit") //edit
                    {
                        TblRight right = _rightRepository.GetById(rightViewModel.RightId);

                        if (right != null)
                        {
                            right.RightId     = rightViewModel.RightId;
                            right.RightName   = rightViewModel.RightName;
                            right.RightTitle  = rightViewModel.RightTitle;
                            right.Description = rightViewModel.Description;

                            right.ApplicationId = rightViewModel.ApplicationId;
                            right.ModuleId      = rightViewModel.ModuleId;

                            _rightRepository.Update(right);
                        }
                        else
                        {
                            return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, rightViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageForNullObject())));
                        }
                    }

                    _rightRepository.Save();

                    return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.TrueString, rightViewModel.ActionName, MessageType.success.ToString(), "Saved Successfully.")));
                }

                return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, rightViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ModelStateErrorFormat(ModelState))));
            }
            catch (Exception ex)
            {
                return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, rightViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageFormat(ex))));
            }
        }
Пример #2
0
        public ActionResult Save(GroupViewModel groupViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //add
                    if (groupViewModel.GroupId == 0 && groupViewModel.ActionName == "Add")
                    {
                        var model = new TblGroup()
                        {
                            GroupId     = groupViewModel.GroupId,
                            GroupName   = groupViewModel.GroupName,
                            Description = groupViewModel.Description,
                            //ApplicationId = groupViewModel.ApplicationId,
                            //ModuleId = groupViewModel.ModuleId
                        };

                        //_groupRepository.Insert(model);
                        //add role to group wise
                    }
                    else if (groupViewModel.ActionName == "Edit") //edit
                    {
                        TblGroup group = _groupRepository.GetById(groupViewModel.GroupId);

                        if (group != null)
                        {
                            group.GroupId     = groupViewModel.GroupId;
                            group.GroupName   = groupViewModel.GroupName;
                            group.Description = groupViewModel.Description;

                            //group.ApplicationId = groupViewModel.ApplicationId;
                            //group.ModuleId = groupViewModel.ModuleId;

                            //_groupRepository.Update(group);
                        }
                        else
                        {
                            return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, groupViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageForNullObject())));
                        }
                    }

                    //_groupRepository.Save();

                    return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.TrueString, groupViewModel.ActionName, MessageType.success.ToString(), "Saved Successfully.")));
                }

                return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, groupViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ModelStateErrorFormat(ModelState))));
            }
            catch (Exception ex)
            {
                return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, groupViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageFormat(ex))));
            }
        }
Пример #3
0
        public ActionResult Save(CompanyViewModel companyViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //add
                    if (companyViewModel.CompanyId == 0 && companyViewModel.ActionName == "Add")
                    {
                        var model = new TblCompany()
                        {
                            CompanyId = companyViewModel.CompanyId + 1, CompanyName = companyViewModel.CompanyName, Address = companyViewModel.Address, CreatedBy = "Rasel", CreatedDate = DateTime.Now, UpdatedBy = "Rasel", UpdatedDate = DateTime.Now
                        };

                        _companyRepository.Insert(model);
                    }
                    else if (companyViewModel.ActionName == "Edit") //edit
                    {
                        TblCompany company = _companyRepository.GetById(Convert.ToInt32(companyViewModel.CompanyId));

                        if (company != null)
                        {
                            company.CompanyId   = companyViewModel.CompanyId;
                            company.CompanyName = companyViewModel.CompanyName;
                            company.Address     = companyViewModel.Address;
                            company.UpdatedBy   = "Rasel";
                            company.UpdatedDate = DateTime.Now;

                            _companyRepository.Update(company);
                        }
                        else
                        {
                            return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, companyViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageForNullObject())));
                        }
                    }

                    _companyRepository.Save();

                    return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.TrueString, companyViewModel.ActionName, MessageType.success.ToString(), "Saved Successfully.")));
                }

                return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, companyViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ModelStateErrorFormat(ModelState))));
            }
            catch (Exception ex)
            {
                return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, companyViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageFormat(ex))));
            }
        }
Пример #4
0
        public ActionResult Save(ApplicationViewModel applicationViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //add
                    if (applicationViewModel.ApplicationId == 0 && applicationViewModel.ActionName == "Add")
                    {
                        var model = new TblApplication()
                        {
                            ApplicationId = applicationViewModel.ApplicationId, ApplicationName = applicationViewModel.ApplicationName, Description = applicationViewModel.Description, ApplicationTitle = applicationViewModel.ApplicationTitle, CompanyId = applicationViewModel.CompanyId
                        };

                        _applicationRepository.Insert(model);
                    }
                    else if (applicationViewModel.ActionName == "Edit") //edit
                    {
                        TblApplication application = _applicationRepository.GetById(applicationViewModel.ApplicationId);

                        if (application != null)
                        {
                            application.ApplicationId    = applicationViewModel.ApplicationId;
                            application.ApplicationName  = applicationViewModel.ApplicationName;
                            application.Description      = applicationViewModel.Description;
                            application.ApplicationTitle = applicationViewModel.ApplicationTitle;
                            application.CompanyId        = applicationViewModel.CompanyId;

                            _applicationRepository.Update(application);
                        }
                        else
                        {
                            return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, applicationViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageForNullObject())));
                        }
                    }

                    _applicationRepository.Save();

                    return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.TrueString, applicationViewModel.ActionName, MessageType.success.ToString(), "Saved Successfully.")));
                }

                return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, applicationViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ModelStateErrorFormat(ModelState))));
            }
            catch (Exception ex)
            {
                return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, applicationViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageFormat(ex))));
            }
        }
Пример #5
0
        public ActionResult Save(ModuleViewModel moduleViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //add
                    if (moduleViewModel.ModuleId == 0 && moduleViewModel.ActionName == "Add")
                    {
                        var model = new TblModule()
                        {
                            ModuleId = moduleViewModel.ModuleId, ModuleName = moduleViewModel.ModuleName, Description = moduleViewModel.Description, ModuleTitle = moduleViewModel.ModuleTitle, ApplicationId = moduleViewModel.ApplicationId
                        };

                        _moduleRepository.Insert(model);
                    }
                    else if (moduleViewModel.ActionName == "Edit") //edit
                    {
                        TblModule module = _moduleRepository.GetById(moduleViewModel.ModuleId);

                        if (module != null)
                        {
                            module.ModuleId      = moduleViewModel.ModuleId;
                            module.ModuleName    = moduleViewModel.ModuleName;
                            module.Description   = moduleViewModel.Description;
                            module.ModuleTitle   = moduleViewModel.ModuleTitle;
                            module.ApplicationId = moduleViewModel.ApplicationId;

                            _moduleRepository.Update(module);
                        }
                        else
                        {
                            return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, moduleViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageForNullObject())));
                        }
                    }

                    _moduleRepository.Save();

                    return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.TrueString, moduleViewModel.ActionName, MessageType.success.ToString(), "Saved Successfully.")));
                }

                return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, moduleViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ModelStateErrorFormat(ModelState))));
            }
            catch (Exception ex)
            {
                return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, moduleViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageFormat(ex))));
            }
        }
Пример #6
0
        public ActionResult Save(UserViewModel userViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //add
                    if (userViewModel.UserId == 0 && userViewModel.ActionName == "Add")
                    {
                        var model = new TblUser()
                        {
                            LoginId      = userViewModel.LoginId,
                            Password     = userViewModel.Password,
                            UserName     = userViewModel.UserName,
                            EmailAddress = userViewModel.EmailAddress,
                            Phone        = userViewModel.Phone,
                            ChangePasswordAtFirstLogin = userViewModel.ChangePasswordAtFirstLogin,
                            Status = userViewModel.Status,

                            GroupId       = userViewModel.GroupId,
                            ApplicationId = userViewModel.ApplicationId,
                            EmployeeId    = userViewModel.EmployeeId
                        };

                        //_userRepository.Insert(model);
                    }
                    else if (userViewModel.ActionName == "Edit") //edit
                    {
                        TblUser user = _userRepository.GetById(userViewModel.UserId);

                        if (user != null)
                        {
                            user.UserId       = userViewModel.UserId;
                            user.LoginId      = userViewModel.LoginId;
                            user.Password     = userViewModel.Password;
                            user.UserName     = userViewModel.UserName;
                            user.EmailAddress = userViewModel.EmailAddress;
                            user.Phone        = userViewModel.Phone;
                            user.ChangePasswordAtFirstLogin = userViewModel.ChangePasswordAtFirstLogin;
                            user.Status = userViewModel.Status;

                            user.ApplicationId = userViewModel.ApplicationId;
                            user.GroupId       = userViewModel.GroupId;
                            user.EmployeeId    = userViewModel.EmployeeId;

                            //_userRepository.Update(user);
                        }
                        else
                        {
                            return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, userViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageForNullObject())));
                        }
                    }

                    //_userRepository.Save();

                    return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.TrueString, userViewModel.ActionName, MessageType.success.ToString(), "Saved Successfully.")));
                }

                return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, userViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ModelStateErrorFormat(ModelState))));
            }
            catch (Exception ex)
            {
                return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, userViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageFormat(ex))));
            }
        }
Пример #7
0
        public ActionResult Save(MenuViewModel menuViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //add
                    if (menuViewModel.MenuId == 0 && menuViewModel.ActionName == "Add")
                    {
                        var model = new TblMenu()
                        {
                            MenuId         = menuViewModel.MenuId,
                            MenuName       = menuViewModel.MenuName,
                            MenuCaption    = menuViewModel.MenuCaption,
                            MenuCaptionBng = menuViewModel.MenuCaptionBng,
                            PageUrl        = menuViewModel.PageUrl,
                            SerialNo       = menuViewModel.SerialNo,
                            OrderNo        = menuViewModel.OrderNo,
                            ParentMenuId   = menuViewModel.ParentMenuId,
                            ApplicationId  = menuViewModel.ApplicationId,
                            ModuleId       = menuViewModel.ModuleId
                        };

                        _menuRepository.Insert(model);
                    }
                    else if (menuViewModel.ActionName == "Edit") //edit
                    {
                        TblMenu menu = _menuRepository.GetById(menuViewModel.MenuId);

                        if (menu != null)
                        {
                            menu.MenuId         = menuViewModel.MenuId;
                            menu.MenuName       = menuViewModel.MenuName;
                            menu.MenuCaption    = menuViewModel.MenuCaption;
                            menu.MenuCaptionBng = menuViewModel.MenuCaptionBng;
                            menu.PageUrl        = menuViewModel.PageUrl;
                            menu.SerialNo       = menuViewModel.SerialNo;
                            menu.OrderNo        = menuViewModel.OrderNo;
                            menu.ParentMenuId   = menuViewModel.ParentMenuId;
                            menu.ApplicationId  = menuViewModel.ApplicationId;
                            menu.ModuleId       = menuViewModel.ModuleId;

                            _menuRepository.Update(menu);
                        }
                        else
                        {
                            return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, menuViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageForNullObject())));
                        }
                    }

                    _menuRepository.Save();

                    return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.TrueString, menuViewModel.ActionName, MessageType.success.ToString(), "Saved Successfully.")));
                }

                return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, menuViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ModelStateErrorFormat(ModelState))));
            }
            catch (Exception ex)
            {
                return(Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.FalseString, menuViewModel.ActionName, MessageType.warning.ToString(), ExceptionHelper.ExceptionMessageFormat(ex))));
            }
        }