Exemple #1
0
        /// <summary>
        /// Used to activate the user account
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public static UserActivationModel ActivateUser(string uid)
        {
            try
            {
                using (var nie = new NewsIndiaTVEntities())
                {
                    var guidInfo = nie.AuthenticationLinks.FirstOrDefault(m => m.UnqiueLink == uid && !m.IsUsed);
                    if (guidInfo != null && guidInfo.VerificationTypeId == 1)
                    {
                        var userInfo = nie.UserMasters.FirstOrDefault(m => m.Id == guidInfo.UserId);
                        if (userInfo != null)
                        {
                            userInfo.IsEnabled = true;
                            guidInfo.IsUsed = true;
                            nie.SaveChanges();
                            return new UserActivationModel()
                            {
                                UserId = userInfo.Id,
                                UserName = userInfo.FirstName + (userInfo.MiddleName == null ? ("") : " " + userInfo.MiddleName) + " " + userInfo.LastName
                            };
                        }

                    }
                    return new UserActivationModel();
                }
            }
            catch (Exception ex)
            {
                return new UserActivationModel();
            }
        }
 /// <summary>
 /// Used to get the lastest 10 news to display in the breaking news
 /// </summary>
 /// <returns></returns>
 public static List<SubCategoryModel> GetLatestNews()
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return nie.SubCategoryDataMasters.Where(m => m.IsVisible).OrderByDescending(m => m.SubmittedDate).Take(10).Select(
                 m => new SubCategoryModel()
                 {
                     Title = m.Title,
                     Description = m.Description,
                     SubCategoryDataId = m.ID,
                     Attachments = m.SubCategoryDataAttachments.Where(c => c.SubCategoryDataID == m.ID).Select(
                     c => new SubCategoryAttachment()
                     {
                         FileName = c.FileName,
                         FileType = (AttachmentType)c.AttachmentID,
                         SubCategoryAttachmentId = c.ID
                     }).ToList()
                 }
                 ).ToList();
         }
     }
     catch (Exception ex)
     {
         return new List<SubCategoryModel>();
     }
 }
 /// <summary>
 /// Used to get List of the subCategory
 /// </summary>
 /// <returns></returns>
 public static List<SubCategoryModel> GetSubCategoryListView(int subCategory = 0)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return nie.SubCategoryDataMasters.Where(m => m.SubCategoryId == subCategory && m.IsVisible && m.IsActive).Select(
                 m => new SubCategoryModel()
                 {
                     Title = m.Title,
                     Description = m.Description,
                     SubCategoryDataId = m.ID,
                     Attachments = m.SubCategoryDataAttachments.Where(c => c.SubCategoryDataID == m.ID).Select(
                     c => new SubCategoryAttachment()
                     {
                         FileName = c.FileName,
                         FileType = (AttachmentType)c.AttachmentID,
                         SubCategoryAttachmentId = c.ID
                     }).ToList()
                 }
                 ).ToList();
         }
     }
     catch (Exception ex)
     {
         return new List<SubCategoryModel>();
     }
 }
        public static SubCategoryModel GetSubCategoryData(int subCategoryDataId = 0)
        {
            try
            {
                using (var nie = new NewsIndiaTVEntities())
                {

                    //var subCategoryData = nie.SubCategoryDataMasters.FirstOrDefault(m => m.ID == subCategoryDataId && m.IsVisible);
                    //var categoryDataModel = new SubCategoryModel()
                    //{
                    //    Title = subCategoryData.Title,
                    //    Description = subCategoryData.Description,
                    //    SubCategoryDataId = subCategoryData.ID,
                    //    Attachments = new List<SubCategoryAttachment>()
                    //};

                    //foreach (var attachment in nie.SubCategoryDataAttachments.Where(m => m.SubCategoryDataID == subCategoryData.ID))
                    //{
                    //    var attachmentInfo= new SubCategoryAttachment()
                    //    {
                    //        FileName = attachment.FileName,
                    //        FileType = (AttachmentType)attachment.AttachmentID,
                    //        SubCategoryAttachmentId = attachment.ID
                    //    };
                    //    categoryDataModel.Attachments.Add(attachmentInfo);

                    //}
                    //return categoryDataModel;
                    var subcategoryInfo =
                                         nie.SubCategoryDataMasters.FirstOrDefault(m => m.ID == subCategoryDataId && m.IsVisible);
                    return new SubCategoryModel()
                    {
                        Description = subcategoryInfo.Description,
                        SubCategoryDataId = subcategoryInfo.ID,
                        Title = subcategoryInfo.Title,
                        Attachments = subcategoryInfo.SubCategoryDataAttachments.Select(m => new SubCategoryAttachment()
                        {
                            FileName = m.FileName,
                            FileType = (AttachmentType)m.AttachmentID,
                            SubCategoryAttachmentId = m.ID
                        }).ToList()
                    };

                }
            }
            catch (Exception ex)
            {
                return new SubCategoryModel();
            }
        }
Exemple #5
0
 /// <summary>
 /// Used to get the active categories
 /// </summary>
 /// <returns></returns>
 public static List<UserMaster> GetActiveUsers()
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return nie.UserMasters.Where(m => m.IsActive).ToList();
         }
     }
     catch (Exception ex)
     {
         return new List<UserMaster>();
     }
 }
 /// <summary>
 /// Used to get the information of the Category
 /// </summary>
 /// <returns></returns>
 public static CategoryMaster GetCategoryInfo(int categoryId = 0)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return nie.CategoryMasters.FirstOrDefault(m => m.IsActive && m.ID == categoryId);
         }
     }
     catch (Exception ex)
     {
         return new CategoryMaster();
     }
 }
 /// <summary>
 /// Used to get Information about SubCategory
 /// </summary>
 /// <param name="subCategoryId"></param>
 /// <returns></returns>
 public static string GetSubCategoryInformation(int subCategoryId = 0)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return nie.SubCategoryMasters.FirstOrDefault(m => m.ID == subCategoryId).SubCategoryName;
         }
     }
     catch (Exception ex)
     {
         return "";
     }
 }
Exemple #8
0
 /// <summary>
 /// Used to get the Information about the side banner
 /// </summary>
 /// <returns></returns>
 public static List<SideBannerMaster> GetSideBanner()
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return nie.SideBannerMasters.Where(m => m.IsActive && m.IsVisible).ToList();
         }
     }
     catch (Exception ex)
     {
         return new List<SideBannerMaster>();
     }
 }
 /// <summary>
 /// Used to check if the category Name is Already present
 /// </summary>
 /// <param name="categoryName"></param>
 /// <param name="categoryId"></param>
 /// <returns></returns>
 public static bool CheckCategoryName(string categoryName,int categoryId)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return nie.CategoryMasters.Any(m => m.IsActive && m.CategoryName == categoryName && m.ID != categoryId);
         }
     }
     catch (Exception ex)
     {
         return false;
     }
 }
Exemple #10
0
 /// <summary>
 /// Used to Get all the roles available except super admin
 /// </summary>
 /// <returns></returns>
 public static List<RoleInformation> GetRoles()
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return
                 nie.UserRoles.Where(m => m.Id != 1 && m.IsActive)
                     .Select(m => new RoleInformation() { RoleId = m.Id, RoleName = m.Name }).ToList();
         }
     }
     catch (Exception ex)
     {
         return new List<RoleInformation>();
     }
 }
 /// <summary>
 /// Used to get the information of the SubCategory
 /// </summary>
 /// <returns></returns>
 public static SubCategoryMaster GetSubCategoryInfo(int subCategoryId = 0)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             var subCategoryInfo= nie.SubCategoryMasters.FirstOrDefault(m => m.ID == subCategoryId && m.IsActive);
             if (subCategoryInfo != null && !subCategoryInfo.CategoryMaster.IsActive)
                 subCategoryInfo.CategoryID = 0;
             return subCategoryInfo;
         }
     }
     catch (Exception ex)
     {
         return new SubCategoryMaster();
     }
 }
 /// <summary>
 /// Used to get the active categories
 /// </summary>
 /// <returns></returns>
 public static List<ActiveCategory> GetActiveCategories()
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return
                 nie.CategoryMasters.Where(m => m.IsActive)
                     .Select(m => new ActiveCategory() { CategoryName = m.CategoryName, CategoryId = m.ID })
                     .ToList();
         }
     }
     catch (Exception ex)
     {
         return new List<ActiveCategory>();
     }
 }
 /// <summary>
 /// Used to check if the Subcategory Already exist
 /// </summary>
 /// <param name="subCategoryName"></param>
 /// <param name="subCategoryId"></param>
 /// <param name="categoryId"></param>
 /// <returns></returns>
 public static bool CheckSubCategoryName(string subCategoryName, int subCategoryId, int categoryId)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return
                 nie.SubCategoryMasters.Any(
                     m =>
                         m.SubCategoryName == subCategoryName && (subCategoryId == 0 || m.ID != subCategoryId) &&
                         m.CategoryMaster.ID == categoryId && m.IsActive);
         }
     }
     catch (Exception ex)
     {
         return false;
     }
 }
        /// <summary>
        /// Used to remove the Category
        /// </summary>
        /// <param name="categoryId"></param>
        /// <returns></returns>
        public static bool RemoveCategory(int categoryId)
        {
            try
            {
                using (var nie = new NewsIndiaTVEntities())
                {
                    var categoryInfo = nie.CategoryMasters.FirstOrDefault(m => m.ID == categoryId);
                    if (categoryInfo != null)
                        categoryInfo.IsActive = false;
                    nie.SaveChanges();

                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
Exemple #15
0
 /// <summary>
 /// Used to get List of the subCategory
 /// </summary>
 /// <returns></returns>
 public static UserMaster GetLoginInfo(LoginInfo loginInfo)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
         
             var userInfo=
                 nie.UserMasters.FirstOrDefault(
                     m => m.Email == loginInfo.UserName && m.Password == loginInfo.Password && m.IsActive);
             
             return userInfo;
         }
     }
     catch (Exception ex)
     {
         return null;
     }
 }
Exemple #16
0
 /// <summary>
 /// Used to get state information based on country id
 /// </summary>
 /// <returns></returns>
 public static List<StateInformation> GetStateByCountry(int countryId)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return nie.States.Where(m => m.IsActive && m.CountryId==countryId).Select(
                 m => new StateInformation()
                 {
                     StateId = m.StateId,
                     StateName = m.StateName,
                 }
                 ).ToList();
         }
     }
     catch (Exception ex)
     {
         return new List<StateInformation>();
     }
 }
Exemple #17
0
 public static List<StateMaster> GetStateList()
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return nie.States.Where(m => m.IsActive).Select(
                 m => new StateMaster()
                 {
                     StateId = m.StateId,
                     StateName = m.StateName,
                 }
                 ).ToList();
         }
     }
     catch (Exception ex)
     {
         return new List<StateMaster>();
     }
 }
Exemple #18
0
 public static List<CountryMaster> GetCountryList()
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return nie.Countries.Where(m=>m.IsActive).Select(
                 m => new CountryMaster()
                 {
                     CountryId = m.CountryId,
                     CountryName = m.CountryName,
                 }
                 ).ToList();
         }
     }
     catch (Exception ex)
     {
         return new List<CountryMaster>();
     }
 }
Exemple #19
0
 /// <summary>
 /// Used to get user by id
 /// </summary>
 /// <returns></returns>
 public static UserViewModel GetUserById(int userId = 0)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             var um = nie.UserMasters.FirstOrDefault(m => m.Id == userId && m.IsActive);
             return new UserViewModel()
             {
                 UserId = um.Id,
                 FirstName = um.FirstName,
                 LastName = um.LastName,
                 MiddleName = um.MiddleName,
                 Gender = um.Gender,
                 EmailId = um.Email,
                 //Password = um.Password,
                 MobileNumber = um.PhoneNumber,
                 Address = um.Address,
                 City = um.City,
                 // StateName = um.State,
                 //CountryName = um.Country,
                 State = um.StateID,
                 Country = um.CountryID,
                 PinCode = um.Pincode,
                 IsActive = um.IsActive,
                 CreatedBy = um.CreatedBy,
                 CreatedOn = um.CreatedOn,
                 ModifiedBy = um.ModifiedBy,
                 ModifiedOn = um.ModifiedOn,
                 DateOfBirth = Convert.ToDateTime(um.DateOfBirth),
                 IsEnabled = Convert.ToBoolean(um.IsEnabled),
                 SelectedRoleId = um.RoleId
             };
         }
     }
     catch (Exception ex)
     {
         return new UserViewModel();
     }
 }
 /// <summary>
 /// used to create authentication link for the authentication
 /// </summary>
 /// <param name="uid"></param>
 /// <param name="authenticationTypeId"></param>
 /// <returns></returns>
 public static bool CreateAuthenticationLink(string uid, int authenticationTypeId, int userId)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             nie.AuthenticationLinks.Add(new AuthenticationLink()
             {
                 IsUsed = false,
                 UnqiueLink = uid,
                 UserId = userId,
                 VerificationTypeId = authenticationTypeId
             });
             nie.SaveChanges();
             return true;
         }
     }
     catch (Exception ex)
     {
         return false;
     }
 }
Exemple #21
0
 /// <summary>
 /// Used to get menu for layout
 /// </summary>
 /// <returns></returns>
 public static List<Category> GetMenuList()
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return nie.CategoryMasters.Where(m => m.IsActive && m.IsVisible).Select(menu => new Category()
              {
                  CategoryName = menu.CategoryName,
                  CategoryId = menu.ID,
                  SubCategory =
                      menu.SubCategoryMasters.Where(m => m.CategoryID == menu.ID && m.IsActive && m.IsVisible).Select(n => new SubCategory()
                      {
                          SubCategoryId = n.ID,
                          SubCategoryName = n.SubCategoryName
                      }).ToList()
              }).ToList();
         }
     }
     catch (Exception ex)
     {
         return new List<Category>();
     }
 }
        /// <summary>
        /// Used to Add or Update Sub Category Data
        /// </summary>
        /// <param name="subCategoryDataInfoModel"></param>
        /// <param name="subCategoryDataId"></param>
        /// <returns></returns>
        public static bool AddEditSubCategoryData(
        SubCategoryDataInfoModel subCategoryDataInfoModel, int subCategoryDataId = 0)
        {
            try
            {
                using (var nie = new NewsIndiaTVEntities())
                {
                    var subCategoryData = new SubCategoryDataMaster();
                    if (subCategoryDataId != 0)
                        subCategoryData = nie.SubCategoryDataMasters.FirstOrDefault(m => m.ID == subCategoryDataId);

                    subCategoryData.IsActive = true;
                    subCategoryData.Title = subCategoryDataInfoModel.Title;
                    subCategoryData.Description = subCategoryDataInfoModel.Description;
                    subCategoryData.IsVisible = subCategoryDataInfoModel.IsVisible;
                    subCategoryData.SubCategoryId = subCategoryDataInfoModel.SubCategoryId;
                    subCategoryData.IsSuperAdminApproved = subCategoryDataInfoModel.IsVisible;

                    if (subCategoryDataId == 0)
                    {
                        subCategoryData.SubmittedDate = DateTime.Now;
                        subCategoryData.SavedTimeStamp = subCategoryDataInfoModel.TimeStamp;
                        nie.SubCategoryDataMasters.Add(subCategoryData);
                    }
                    nie.SaveChanges();

                    if (subCategoryDataInfoModel.UploadedFileNames != null)
                    {
                        var uploadedFiles = new List<SubCategoryDataAttachment>();
                        if (subCategoryDataId != 0)
                        {
                            uploadedFiles =
                                nie.SubCategoryDataAttachments.Where(m => m.SubCategoryDataID == subCategoryDataId && m.IsActive).ToList();
                            foreach (var uploadedFile in uploadedFiles)
                            {
                                uploadedFile.IsActive = false;
                                nie.SaveChanges();
                            }

                        }
                        if(subCategoryDataInfoModel.UploadedFileNames!="")
                        foreach (var fileInfo in subCategoryDataInfoModel.UploadedFileNames.Split(','))
                        {

                            // var fileType=
                            var fileInformation = uploadedFiles.FirstOrDefault(m => m.FileName == fileInfo);
                            if (fileInformation != null)
                                fileInformation.IsActive = true;
                            else
                            {
                                nie.SubCategoryDataAttachments.Add(new SubCategoryDataAttachment()
                                {
                                    FileName = fileInfo,
                                    SubCategoryDataID = subCategoryData.ID,
                                    AttachmentID = Convert.ToInt32(GetAttachmentType(fileInfo)),
                                    IsActive = true,
                                });
                            }
                            nie.SaveChanges();
                        }
                    }
                    return true;
                }
            }
            catch (Exception ex)
            {
                return false;
            }
        }
 /// <summary>
 /// Used to get the list of all the subCatgories present under the category
 /// </summary>
 /// <param name="categoryId"></param>
 /// <returns></returns>
 public static List<SubCategoryInformation> GetSubCategories(int categoryId)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return
                 nie.SubCategoryMasters.Where(m => m.CategoryID == categoryId && m.IsActive)
                     .Select(m => new SubCategoryInformation()
                     {
                         SubCategoryId = m.ID,
                         SubCategoryName = m.SubCategoryName
                     }).ToList();
         }
     }
     catch (Exception ex)
     {
         return new List<SubCategoryInformation>();
     }
 }
Exemple #24
0
        /// <summary>
        /// Used to save the User Information
        /// </summary>
        /// <returns></returns>
        public static int SaveUserInformation(UserViewModel um, bool requestForPasswordChange, bool isAdminSave,
            int? loggedInUser = null)
        {
            try
            {
                using (var nie = new NewsIndiaTVEntities())
                {
                    if (um.UserId != 0)
                    {
                        var userInfo = nie.UserMasters.FirstOrDefault(m => m.Id == um.UserId & m.IsActive);
                        if (userInfo != null)
                        {

                            userInfo.FirstName = um.FirstName;
                            userInfo.LastName = um.LastName;
                            userInfo.MiddleName = um.MiddleName;
                            userInfo.Gender = um.Gender;
                           // userInfo.Email = um.EmailId;
                            userInfo.PhoneNumber = um.MobileNumber;
                            userInfo.DateOfBirth = um.DateOfBirth;

                            if (requestForPasswordChange)
                                userInfo.Password = um.Password;

                            userInfo.Address = um.Address;
                            userInfo.City = um.City;
                            userInfo.StateID = um.State;
                            userInfo.CountryID = um.Country;
                            userInfo.Pincode = um.PinCode;
                            userInfo.ModifiedBy = loggedInUser;
                            userInfo.ModifiedOn = DateTime.Now;
                            if (isAdminSave)
                            {
                                userInfo.RoleId = um.SelectedRoleId;
                                userInfo.IsEnabled = um.IsEnabled;
                            }
                            nie.SaveChanges();
                            return userInfo.Id;
                        }
                        return 0;

                    }
                    else
                    {
                        var userData = new UserMaster()
                         {

                             FirstName = um.FirstName,
                             LastName = um.LastName,
                             MiddleName = um.MiddleName,
                             Gender = um.Gender,
                             Email = um.EmailId,
                             Password = um.Password,
                             PhoneNumber = um.MobileNumber,
                             Address = um.Address,
                             City = um.City,
                             StateID = um.State,
                             CountryID = um.Country,
                             Pincode = um.PinCode,
                             IsActive = true,
                             CreatedBy = loggedInUser,
                             CreatedOn = DateTime.Now,
                             ModifiedBy = loggedInUser,
                             ModifiedOn = DateTime.Now,
                             DateOfBirth = um.DateOfBirth

                         };

                        if (isAdminSave)
                        {
                            userData.RoleId = um.SelectedRoleId;
                            userData.IsEnabled = um.IsEnabled;
                        }
                        else
                        {
                            userData.RoleId = 3;
                            userData.IsEnabled = false;
                        }
                        nie.UserMasters.Add(userData);
                        nie.SaveChanges();
                        return userData.Id;
                    }

                }
            }
            catch (Exception ex)
            {
                return 0;
            }
        }
Exemple #25
0
 /// <summary>
 /// Used to Remove user
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public static bool RemoveUser(int userId)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             var user = nie.UserMasters.FirstOrDefault(m => m.Id == userId);
             if (user != null)
                 user.IsActive = false;
             nie.SaveChanges();
             return true;
         }
     }
     catch (Exception ex)
     {
         return false;
         ;
     }
 }
Exemple #26
0
 /// <summary>
 /// Used to check if the email address exist in database
 /// </summary>
 /// <param name="emailId"></param>
 /// <returns></returns>
 public static bool IsEmailExist(string emailId)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return nie.UserMasters.Any(m => m.Email == emailId & m.IsActive);
         }
     }
     catch (Exception ex)
     {
         return false;
     }
 }
Exemple #27
0
        /// <summary>
        /// Used to get users information for grid 
        /// </summary>
        /// <returns></returns>
        public static List<UserModelGrid> GetUsersForMasterGrid()
        {
            try
            {
                using (var nie = new NewsIndiaTVEntities())
                {
                    var adminRoleId = nie.UserRoles.FirstOrDefault(m => m.Name == "admin") ?? new UserRole() { Id = 0 };

                    return nie.UserMasters.Where(m => m.IsActive).Select(m => new UserModelGrid()
                    {
                        EmailId = m.Email,
                        FirstName = m.FirstName,
                        LastName = m.LastName,
                        IsAdmin = m.RoleId == adminRoleId.Id,
                        MiddleName = m.MiddleName,
                        PhoneNumber = m.PhoneNumber,
                        RoleId = m.RoleId,
                        UserId = m.Id

                    }).ToList();
                }
            }
            catch (Exception ex)
            {
                return new List<UserModelGrid>();
            }
        }
        /// <summary>
        /// used to save the category info in the database
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="categoryName"></param>
        /// <param name="isVisible"></param>
        /// <returns></returns>
        public static bool SaveCategoryInfo(int categoryId, string categoryName, bool isVisible)
        {
            try
            {
                using (var nie = new NewsIndiaTVEntities())
                {
                    var categoryMaster = nie.CategoryMasters.FirstOrDefault(m => m.ID == categoryId);

                    if (categoryMaster != null)
                    {
                        categoryMaster.CategoryName = categoryName;
                        categoryMaster.IsVisible = isVisible;
                    }
                    else
                    {
                        categoryMaster = new CategoryMaster()
                            {
                                CategoryName = categoryName,
                                IsVisible = isVisible,
                                IsActive = true
                            };
                        nie.CategoryMasters.Add(categoryMaster);
                    }
                    nie.SaveChanges();

                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// Used to save the subCategory Information
        /// </summary>
        /// <param name="subCategoryId"></param>
        /// <param name="subCategoryName"></param>
        /// <param name="isVisible"></param>
        /// <param name="categoryId"></param>
        /// <returns></returns>
        public static bool SaveSubCategoryInfo(int subCategoryId, string subCategoryName, bool isVisible, int categoryId)
        {
            try
            {
                using (var nie = new NewsIndiaTVEntities())
                {
                    var subCategoryMaster = nie.SubCategoryMasters.FirstOrDefault(m => m.ID == subCategoryId);

                    if (subCategoryMaster != null)
                    {
                        subCategoryMaster.SubCategoryName = subCategoryName;
                        subCategoryMaster.IsVisible = isVisible;
                        subCategoryMaster.CategoryID = categoryId;
                    }
                    else
                    {
                        subCategoryMaster = new SubCategoryMaster()
                            {
                                SubCategoryName = subCategoryName,
                                IsVisible = isVisible,
                                IsActive = true,
                                CategoryID = categoryId
                            };
                        nie.SubCategoryMasters.Add(subCategoryMaster);
                    }
                    nie.SaveChanges();

                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
 /// <summary>
 /// Used to get the list of all the SubCategories
 /// </summary>
 /// <param name="categoryId"></param>
 public static List<SubCategoryTableModel> GetSubCategoryList(int categoryId = 0)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return
                 nie.SubCategoryMasters.Where(m => m.IsActive && (categoryId == 0 || m.CategoryID == categoryId))
                     .Select(m => new SubCategoryTableModel()
                         {
                             SubCategoryName = m.SubCategoryName,
                             IsVisible = m.IsVisible,
                             SubCategoryId = m.ID,
                             CategoryName = m.CategoryMaster.IsActive?m.CategoryMaster.CategoryName:"-",
                             SubCategoryShowing = (m.IsVisible && m.CategoryMaster.IsVisible && m.CategoryMaster.IsActive),
                             IsCategoryVisible = m.CategoryMaster.IsVisible,
                             IsCategoryActive = m.CategoryMaster.IsActive
                         }
                     ).ToList();
         }
     }
     catch (Exception ex)
     {
         return new List<SubCategoryTableModel>();
     }
 }