/// <summary>
 /// Create a new TblModule object.
 /// </summary>
 /// <param name="moduleId">Initial value of the ModuleId property.</param>
 /// <param name="applicationId">Initial value of the ApplicationId property.</param>
 /// <param name="moduleName">Initial value of the ModuleName property.</param>
 public static TblModule CreateTblModule(global::System.Int32 moduleId, global::System.Int32 applicationId, global::System.String moduleName)
 {
     TblModule tblModule = new TblModule();
     tblModule.ModuleId = moduleId;
     tblModule.ApplicationId = applicationId;
     tblModule.ModuleName = moduleName;
     return tblModule;
 }
        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, 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.TrueString, MessageType.success.ToString(), ExceptionHelper.ModelStateErrorFormat(ModelState)));
            }
            catch (Exception ex)
            {
                return Content(KendoUiHelper.GetKendoUiWindowAjaxSuccessMethod(Boolean.TrueString, MessageType.success.ToString(), ExceptionHelper.ExceptionMessageFormat(ex)));
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the TblModules EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTblModules(TblModule tblModule)
 {
     base.AddObject("TblModules", tblModule);
 }