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