Example #1
0
 /// <summary>
 /// Used to get the list of all the SubCategory Data
 /// </summary>
 /// <param name="subCategoryDataId"></param>
 public static List <SubCategoryDataTableModel> GetSubCategoryDataList(int subCategoryDataId = 0)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             return
                 (nie.SubCategoryDataMasters.Where(m => m.IsActive && (subCategoryDataId == 0 || m.SubCategoryId == subCategoryDataId))
                  .Select(m => new SubCategoryDataTableModel()
             {
                 CategoryName = m.SubCategoryMaster.CategoryMaster.CategoryName,
                 IsCategoryActive = m.SubCategoryMaster.CategoryMaster.IsActive,
                 IsCategoryVisible = m.SubCategoryMaster.CategoryMaster.IsVisible,
                 IsVisible = m.IsVisible,
                 IsSubCategoryActive = m.SubCategoryMaster.IsActive,
                 IsSubCategoryVisible = m.SubCategoryMaster.IsVisible,
                 SubCategoryName = m.SubCategoryMaster.SubCategoryName,
                 SubCategoryDataId = m.ID,
                 SubCategoryDataTitle = m.Title,
                 SubCategoryDataShowing = (m.IsVisible && m.SubCategoryMaster.IsActive && m.SubCategoryMaster.IsVisible && m.SubCategoryMaster.CategoryMaster.IsVisible && m.SubCategoryMaster.CategoryMaster.IsActive)
             }
                          ).ToList());
         }
     }
     catch (Exception ex)
     {
         return(new List <SubCategoryDataTableModel>());
     }
 }
Example #2
0
        /// <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);
            }
        }
Example #3
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 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>());
     }
 }
Example #5
0
        /// <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);
            }
        }
Example #6
0
 /// <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>());
     }
 }
Example #7
0
 /// <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>());
     }
 }
Example #8
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>());
            }
        }
Example #9
0
        /// <summary>
        /// Used to get the sub category data information
        /// </summary>
        /// <param name="subCategoryId"></param>
        /// <returns></returns>
        public static SubCategoryDataInfoModel GetSubCategoryDataInformation(int subCategoryId = 0)
        {
            try
            {
                using (var nie = new NewsIndiaTVEntities())
                {
                    var info            = nie.SubCategoryDataMasters.FirstOrDefault(m => m.ID == subCategoryId);
                    var subCategoryData = new SubCategoryDataInfoModel()
                    {
                        Description       = info.Description,
                        SubCategoryDataId = info.ID,
                        Title             = info.Title,
                        IsVisible         = info.IsVisible,
                        SubCategoryId     = info.SubCategoryId,
                        TimeStamp         = info.SavedTimeStamp,
                        CategoryId        = info.SubCategoryMaster.CategoryID,
                        Files             = info.SubCategoryDataAttachments.Where(m => m.IsActive).Select(c => c.FileName).ToList()
                                            //Attachments =
                                            // UploadedFileNames =
                    };
                    foreach (var attachment in info.SubCategoryDataAttachments.Where(m => m.IsActive))
                    {
                        subCategoryData.UploadedFileNames += attachment.FileName.Split('\\')[1] + ",";
                    }

                    return(subCategoryData);
                }
            }
            catch (Exception ex)
            {
                return(new SubCategoryDataInfoModel());
            }
        }
Example #10
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>());
     }
 }
Example #11
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);
     }
 }
Example #12
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>());
     }
 }
Example #13
0
        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());
            }
        }
 /// <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("");
     }
 }
Example #15
0
 /// <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);
     }
 }
Example #16
0
 /// <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());
     }
 }
Example #17
0
 /// <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);
     }
 }
Example #18
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);
            }
        }
Example #19
0
 /// <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());
     }
 }
Example #20
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>());
     }
 }
Example #21
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>());
     }
 }
Example #22
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>());
     }
 }
Example #23
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>());
     }
 }
Example #24
0
 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>());
     }
 }
Example #25
0
 /// <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>());
     }
 }
Example #26
0
 /// <summary>
 /// Used to remove the SubCategory
 /// </summary>
 /// <param name="subCategoryId"></param>
 /// <returns></returns>
 public static bool RemoveSubCategory(int subCategoryId)
 {
     try
     {
         using (var nie = new NewsIndiaTVEntities())
         {
             var subCategoryInfo = nie.SubCategoryMasters.FirstOrDefault(m => m.ID == subCategoryId);
             if (subCategoryInfo != null)
             {
                 subCategoryInfo.IsActive = false;
             }
             nie.SaveChanges();
         }
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #27
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);
     }
 }
Example #29
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);

                ;
            }
        }
Example #30
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>());
     }
 }