Пример #1
0
        public Response <Menus> Post(Menus value)
        {
            try
            {
                var res = BAL_MenuDriver.SaveMenu(value);
                if (res > 0)
                {
                    return new Response <Menus> {
                               Status = true, MessageType = MessageTypes.Success, Message = DisplayMessages.SaveMenus_Success
                    }
                }
                ;
                else
                {
                    return new Response <Menus> {
                               Status = false, MessageType = MessageTypes.Failure, Message = DisplayMessages.SaveMenus_Failure
                    }
                };
            }
            catch (SqlException ex)
            {
                if (ex.Errors.Count > 0)
                {
                    switch (ex.Errors[0].Number)
                    {
                    case 2601:     // Primary key violation
                        return(new Response <Menus> {
                            Status = false, MessageType = MessageTypes.Duplicate, Message = DisplayMessages.SaveMenus_Duplicate
                        });

                    default:
                        return(new Response <Menus> {
                            Status = false, MessageType = MessageTypes.Exception, Message = ex.Message
                        });
                    }
                }
                else
                {
                    return new Response <Menus> {
                               Status = false, MessageType = MessageTypes.Exception, Message = ex.Message
                    }
                };
            }
            catch (Exception ex)
            {
                return(new Response <Menus> {
                    Status = false, MessageType = MessageTypes.Exception, Message = ex.Message
                });
            }
        }
Пример #2
0
        /// <summary>
        /// Function to delete menu
        /// </summary>
        /// <param name="MenuID"></param>
        /// <returns></returns>
        public Response <Menus> Delete(int MenuID)
        {
            try
            {
                var res = BAL_MenuDriver.RemoveMenu(MenuID);
                if (res > 0)
                {
                    return new Response <Menus> {
                               Status = true, MessageType = MessageTypes.Success, Message = DisplayMessages.RemoveMenus_Success
                    }
                }
                ;
                else
                {
                    return new Response <Menus> {
                               Status = false, MessageType = MessageTypes.Failure, Message = DisplayMessages.RemoveMenus_Failure
                    }
                };
            }
            catch (SqlException ex)
            {
                if (ex.Errors.Count > 0)
                {
                    switch (ex.Errors[0].Number)
                    {
                    case 547:     // Foreign Key violation
                        return(new Response <Menus> {
                            Status = false, MessageType = MessageTypes.ForeignKeyIssue, Message = DisplayMessages.RemoveMenus_ForeignKeyIssue
                        });

                    default:
                        return(new Response <Menus> {
                            Status = false, MessageType = MessageTypes.Exception, Message = ex.Message
                        });
                    }
                }
                else
                {
                    return new Response <Menus> {
                               Status = false, MessageType = MessageTypes.Exception, Message = ex.Message
                    }
                };
            }
            catch (Exception ex)
            {
                return(new Response <Menus> {
                    Status = false, MessageType = MessageTypes.Exception, Message = ex.Message
                });
            }
        }
Пример #3
0
 /// <summary>
 /// Function to get the details of selected menu
 /// </summary>
 /// <param name="MenuID"></param>
 /// <returns></returns>
 public Response <Menus> Get(int MenuID)
 {
     try
     {
         return(new Response <Menus> {
             Status = true, Data = BAL_MenuDriver.GetMenuDetails(MenuID) ?? new Menus()
         });
     }
     catch (Exception ex)
     {
         return(new Response <Menus> {
             Status = false, MessageType = MessageTypes.Exception, Message = ex.Message
         });
     }
 }
Пример #4
0
 public Response <disMenus> GetAllMenus(int Module = 0)
 {
     try
     {
         return(new Response <disMenus> {
             Status = true, DataList = BAL_MenuDriver.GetAllMenus(Module, (HttpContext.Current.Session[SessionNames.UserID] != null && Convert.ToInt32(HttpContext.Current.Session[SessionNames.UserID]) > 0) ? Convert.ToInt32(HttpContext.Current.Session[SessionNames.UserID]) : 0) ?? new List <disMenus>()
         });
     }
     catch (Exception ex)
     {
         return(new Response <disMenus> {
             Status = false, MessageType = MessageTypes.Exception, Message = ex.Message
         });
     }
 }