コード例 #1
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());
            }
        }
コード例 #2
0
 /// <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
     {
         return
             (NewsIndiaDAL.SubCategoryDataManager.AddEditSubCategoryData(subCategoryDataInfoModel,
                                                                         subCategoryDataId));
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #3
0
        /// <summary>
        /// Used to display the Subcategory Data and has feature to modify or add the subcategory data
        /// </summary>
        /// <param name="subCategoryDataId"></param>
        /// <returns></returns>
        public ActionResult DisplaySubCategoryData(int subCategoryDataId = 0)
        {
            try
            {
                ViewBag.IsEdit             = subCategoryDataId != 0;
                ViewBag.ActiveCategoryInfo = NewsIndiaBAL.SubCategoryManager.GetActiveCategories();
                SubCategoryDataInfoModel subCategoryDataInfo = subCategoryDataId != 0 ?
                                                               NewsIndiaBAL.SubCategoryDataManager.GetSubCategoryDataInformation(subCategoryDataId) : new SubCategoryDataInfoModel();

                return(View(subCategoryDataInfo));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
コード例 #4
0
        /// <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);
            }
        }
コード例 #5
0
        public ActionResult AddEditSubCategoryData(string description, bool isVisible,
                                                   int SubCategoryId, string timestamp, string UploadedFileNames, string title, string subCategoryDataId)
        {
            try
            {
                var subCategoryDataInfoModel = new SubCategoryDataInfoModel()
                {
                    Description       = description,
                    IsVisible         = Convert.ToBoolean(isVisible),
                    SubCategoryDataId = Convert.ToInt32(subCategoryDataId),
                    SubCategoryId     = Convert.ToInt32(SubCategoryId),
                    TimeStamp         = timestamp,
                    UploadedFileNames = UploadedFileNames,
                    Title             = title
                };
                //if (subCategoryDataInfoModel.Title == null)
                //    return false;

                var currentDate = Convert.ToString(DateTime.Now);

                string timeStamp = Convert.ToInt32(subCategoryDataId) == 0
                    ? CommonHelper.GetTimestamp(Convert.ToDateTime(currentDate))
                    : timestamp;
                //Assigning Time Stamp
                subCategoryDataInfoModel.TimeStamp = timeStamp;

                if (subCategoryDataInfoModel.UploadedFileNames != null)
                {
                    subCategoryDataInfoModel.UploadedFileNames = subCategoryDataInfoModel.UploadedFileNames + ",";
                    var values = subCategoryDataInfoModel.UploadedFileNames.Split(',');
                    subCategoryDataInfoModel.UploadedFileNames = string.Empty;
                    foreach (var value in values)
                    {
                        if (value != "")
                        {
                            subCategoryDataInfoModel.UploadedFileNames += timeStamp + "\\" + value + ",";
                        }
                    }
                }


                if (subCategoryDataInfoModel.UploadedFileNames != null &&
                    subCategoryDataInfoModel.UploadedFileNames != "")
                {
                    subCategoryDataInfoModel.UploadedFileNames = subCategoryDataInfoModel.UploadedFileNames.Substring(0,
                                                                                                                      subCategoryDataInfoModel.UploadedFileNames.Length - 1);

                    //questionMaster.UploadedFileNames = questionMaster.UploadedFileNames.Split('/')[1];
                    //questionMaster.UploadedFileNames = questionMaster.UploadedFileNames + ",";
                    string questionUploadDirectoryPath =
                        Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["AttachmentFilePath"]), timeStamp);
                    NewsIndiaDirectoryManager.CreateDirectory(questionUploadDirectoryPath);

                    //Get to temp directiory Location
                    string tempDirectoryPath =
                        Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["AttachmentFilePath"]),
                                     "TemporaryFiles");
                    NewsIndiaDirectoryManager.CreateDirectory(tempDirectoryPath);

                    string currentUserTempDirectoryPath =
                        Path.Combine(tempDirectoryPath, SessionManager.GetSessionInfo().Id.ToString());


                    string[] files = subCategoryDataInfoModel.UploadedFileNames.Split(',');
                    foreach (string questionFiles in files)
                    {
                        string[] fileEntries = Directory.GetFiles(currentUserTempDirectoryPath);

                        foreach (string fileEntry in fileEntries)
                        {
                            string fileName = timeStamp + "\\" + Path.GetFileName(fileEntry);
                            if (fileName == questionFiles)
                            {
                                string sourceFilePath = Path.Combine(currentUserTempDirectoryPath,
                                                                     fileName.Split('\\')[1]);

                                if (System.IO.File.Exists(sourceFilePath))
                                {
                                    string fileNameToSave = fileName;
                                    string filePath       = Path.Combine(questionUploadDirectoryPath,
                                                                         fileNameToSave.Split('\\')[1]);
                                    // To copy a file to another location and
                                    // overwrite the destination file if it already exists.
                                    System.IO.File.Copy(sourceFilePath, filePath, true);

                                    System.IO.File.Delete(sourceFilePath);
                                }
                            }
                        }
                    }
                }

                var result = NewsIndiaBAL.SubCategoryDataManager.AddEditSubCategoryData(subCategoryDataInfoModel,
                                                                                        Convert.ToInt32(subCategoryDataId));
                if (result != null)
                {
                    var notificationCategoryName = "";

                    notificationCategoryName = "Email abc";
                    //var userDetails = new UserRepository();
                    //var user = userDetails.Find(userId);

                    var emailAddress = ConfigurationManager.AppSettings["AdminEmail"];

                    #region Send Email Notification to User

                    const string mailSubject = "New News Posted";
                    string       mainUrl     = ConfigurationManager.AppSettings["MainURL"];
                    var          sbMailBody  = new StringBuilder();
                    sbMailBody.Append("Hi " + "Akshay" + " " + "Bibekar" + ",");
                    sbMailBody.Append(" <br />Notification !!!");
                    sbMailBody.Append("<br /><br /> Please approve news to show it on website ");
                    sbMailBody.Append("<br /><br /> ");
                    sbMailBody.Append("<strong> Thanks & Regards, <br /> NewsIndia Team </strong>");
                    sbMailBody.Append("<br /><br /> ");

                    #endregion

                    // status = EmailHelper.EmailComposeActionsAndSendEmail(emailAddress, sbMailBody.ToString(), mailSubject, null);
                    SendMail(emailAddress, mailSubject, sbMailBody.ToString(), null);
                    SmsHelper.SmsSend("9766438071,8983563905", "Hi,\nNotification !!!\n Please approve news to show it on website\n\nThanks & Regards,\nNewsIndia Team");

                    return(Json(result, JsonRequestBehavior.AllowGet));

                    /*return Json(NewsIndiaBAL.SubCategoryDataManager.AddEditSubCategoryData(subCategoryDataInfoModel,
                     *                  Convert.ToInt32(subCategoryDataId)), JsonRequestBehavior.AllowGet);*/
                }
            }
            catch (Exception ex)
            {
                return(Json(null, JsonRequestBehavior.AllowGet));

                ;
            }
            // return null;
            return(Json(null, JsonRequestBehavior.AllowGet));
        }