public FilePathResult Download(int id)
        {
            var conventionManager = new DataAccess.ConventionManager();
            var convention = conventionManager.GetConventionDetail(id);
            var fileAttachments = conventionManager.GetAttachmentListOfConvention(id).Select(model => model.FileResource).ToList();

            var outputDirectory = new DirectoryInfo(string.Format("{0}ExportFiles\\{1}\\{2}", Server.MapPath(@"\"), convention.Name, DateTime.Now.ToString("ddMMyyyyhhmmss")));
            var outputDirectoryPathString = System.IO.Path.Combine(outputDirectory.ToString(), "");
            var isExists = System.IO.Directory.Exists(outputDirectoryPathString);
            if (isExists) System.IO.Directory.Delete(outputDirectoryPathString, true);
            System.IO.Directory.CreateDirectory(outputDirectoryPathString);

            foreach (var fileAttachment in fileAttachments)
            {
                var sourceFilePath = Server.MapPath(fileAttachment.path);
                var destFilePath = System.IO.Path.Combine(outputDirectoryPathString, fileAttachment.name);
                if (!System.IO.Directory.Exists(destFilePath))
                {
                    System.IO.File.Copy(sourceFilePath, destFilePath, true);
                }
            }

            var zipOutputDirectory = new DirectoryInfo(string.Format("{0}ExportFiles\\{1}", Server.MapPath(@"\"), convention.Name));
            var zipOutputDirectoryPathString = System.IO.Path.Combine(zipOutputDirectory.ToString(), (DateTime.Now.ToString("ddMMyyyyhhmmss") + ".zip"));
            ZipFile.CreateFromDirectory(outputDirectoryPathString, zipOutputDirectoryPathString);
            return File(zipOutputDirectoryPathString, "application/zip", DateTime.Now.ToString("ddMMyyyyhhmmss") + ".zip");
        }
 public JsonResult DeleteAttachment(int id, int conventionID)
 {
     if (!IsAdmin) { return Json(false); }
     var conventionManager = new DataAccess.ConventionManager();
     var status = conventionManager.DeleteAttachment(id, conventionID);
     return Json(status);
 }
 public ActionResult Detail(int id)
 {
     var convention = new DataAccess.ConventionManager().GetConventionDetail(id);
     //BundleConfig.AddStyle("/Offices", "Detail.css", ControllerName);
     BundleConfig.AddScript("~/Scripts/Conventions", "Detail.js", ControllerName);
     //Script = string.Format("officeDetail.options.officeID = {0};", id);
     return View(convention);
 }
 public PartialViewResult Edit(int id)
 {
     var userDetailManager = new DataAccess.UserManager();
     var officeMananer = new DataAccess.OfficeMananer();
     var user = userDetailManager.GetUserDetail(UserDetail.UserId);
     var offices = officeMananer.GetOffices(IsAdmin ? 0 : UserDetail.UserId);
     ViewData["Offices"] = offices;
     var conventionManager = new DataAccess.ConventionManager();
     var conventions = conventionManager.GetConventions();
     ViewData["Conventions"] = conventions;
     var eventManager = new DataAccess.EventManager();
     var eventDetail = eventManager.GetEventDetail(id);
     return PartialView(eventDetail);
 }
 public PartialViewResult Add()
 {
     var visitTypeManager = new DataAccess.VisitTypeManager();
     ViewData["VisitTypes"] = visitTypeManager.GetVisitTypes();
     var officeManager = new DataAccess.OfficeMananer();
     var offices = officeManager.GetOffices(IsAdmin ? 0 : UserDetail.UserId);
     ViewData["Offices"] = offices;
     var eventManager = new DataAccess.EventManager();
     ViewData["Events"] = eventManager.GetActiveEvents(offices.Select(model => model.OfficeId).ToList());
     var userManager = new DataAccess.FSMDetailManager();
     ViewData["FSMUsers"] = userManager.FSMDetails();
     var conventionManager = new DataAccess.ConventionManager();
     ViewData["Convention"] = conventionManager.GetActiveConventions();
     var serviceManager = new DataAccess.ServiceManager();
     ViewData["Services"] = serviceManager.GetServices();
     return PartialView();
 }
 public ActionResult Add()
 {
     var userDetailManager = new DataAccess.UserManager();
     var officeMananer = new DataAccess.OfficeMananer();
     var user = userDetailManager.GetUserDetail(UserDetail.UserId);
     var offices = officeMananer.GetOffices(IsAdmin ? 0 : UserDetail.UserId);
     ViewData["Offices"] = offices;
     var conventionManager = new DataAccess.ConventionManager();
     var conventions = conventionManager.GetConventions();
     ViewData["Conventions"] = conventions;
     if (IsAdmin)
     {
         var customRoleProvider = new CustomAuthentication.CustomRoleProvider();
         var customMembershipProvider = new CustomAuthentication.CustomMembershipProvider();
         ViewData["Employee"] = customMembershipProvider.GetUsers(4);
     }
     return PartialView();
 }
 public ActionResult Index()
 {
     BundleConfig.AddScript("~/Scripts/Audiences", "audiences.js", ControllerName);
     var officeManager = new DataAccess.OfficeMananer();
     var offices = officeManager.GetOffices(IsAdmin ? 0 : UserDetail.UserId);
     ViewData["Offices"] = offices;
     var eventManager = new DataAccess.EventManager();
     ViewData["Events"] = eventManager.GetActiveEvents(offices.Select(model => model.OfficeId).ToList());
     var userManager = new DataAccess.FSMDetailManager();
     ViewData["FSMUsers"] = userManager.FSMDetails();
     var conventionManager = new DataAccess.ConventionManager();
     ViewData["Convention"] = conventionManager.GetActiveConventions();
     var serviceManager = new DataAccess.ServiceManager();
     ViewData["Services"] = serviceManager.GetServices();
     StartupScript = "audiences.DoPageSetting();";
     return View();
 }
 public PartialViewResult Edit(int id)
 {
     var customRoleProvider = new CustomAuthentication.CustomRoleProvider();
     var roleID = customRoleProvider.GetRole("Speakers");
     var customMembershipProvider = new CustomAuthentication.CustomMembershipProvider();
     var conventionManager = new DataAccess.ConventionManager();
     var conventionDetail = conventionManager.GetConventionDetail(id);
     return PartialView(conventionDetail);
 }
 public JsonResult Add(string name, DateTime startDate, DateTime endDate, string description, int userId, string city)
 {
     if (!IsAdmin) { return Json(false); }
     var conventionManager = new DataAccess.ConventionManager();
     return Json(conventionManager.Add(name, startDate, endDate, description, userId, city));
 }
 public JsonResult UploadFile()
 {
     var status = false;
     HttpPostedFileBase myFile = null;
     if (Request.Files.Count > 0) myFile = Request.Files[0];
     if (myFile != null && myFile.ContentLength != 0)
     {
         string pathForSaving = Server.MapPath("~/ImageUploads");
         if (SharedFunction.CreateFolderIfNeeded(pathForSaving))
         {
             try
             {
                 string fileName = DateTime.Now.ToString("MMddyyyyHHmmss") + Path.GetExtension(myFile.FileName);
                 myFile.SaveAs(Path.Combine(pathForSaving, fileName));
                 string path = "~/ImageUploads/" + fileName;
                 if (!IsAdmin) { return Json(false); }
                 var conventionManager = new DataAccess.ConventionManager();
                 status = conventionManager.Add(Request.Form["name"].ToString(), Convert.ToDateTime(Request.Form["startDate"]), Convert.ToDateTime(Request.Form["endDate"]), Request.Form["description"].ToString(), Convert.ToInt32(Request.Form["userId"]), null, path, myFile.FileName);
             }
             catch (Exception ex)
             {
                 return Json(ex.InnerException);
             }
         }
     }
     return Json(status);
 }
 public JsonResult UploadAttachment()
 {
     var status = false;
     HttpPostedFileBase myFile = null;
     for (int i = 0; i < Request.Files.Count; i++)
     {
         if (Request.Files.Count > 0) myFile = Request.Files[i];
         if (myFile != null && myFile.ContentLength != 0)
         {
             string pathForSaving = Server.MapPath("~/AttachmentUploads");
             if (SharedFunction.CreateFolderIfNeeded(pathForSaving))
             {
                 try
                 {
                     string fileName = DateTime.Now.ToString("MMddyyyyHHmmss") + Path.GetExtension(myFile.FileName);
                     myFile.SaveAs(Path.Combine(pathForSaving, fileName));
                     string path = "~/AttachmentUploads/" + fileName;
                     if (!IsAdmin) { return Json(false); }
                     var conventionManager = new DataAccess.ConventionManager();
                     status = conventionManager.AddAttachment(Convert.ToInt32(Request.Form["conventionID"].ToString()), path, myFile.FileName);
                 }
                 catch (Exception ex)
                 {
                     return Json(ex.InnerException);
                 }
             }
         }
     }
     return Json(status);
 }
 public PartialViewResult UploadAttachment(int id)
 {
     var conventionManager = new DataAccess.ConventionManager();
     var conventionDetail = conventionManager.GetConventionDetail(id);
     var conventionAttachments = conventionManager.GetAttachmentListOfConvention(id);
     ViewData["Attachments"] = conventionAttachments;
     return PartialView(conventionDetail);
 }
 public JsonResult GetConventions(int pageNo = 1, int pageSize = 3)
 {
     var conventionManager = new DataAccess.ConventionManager();
     var conventions = conventionManager.GetConventions();
     var totalRecord = conventions.Count();
     var filteredConventions = conventions.Select(modal => new
     {
         id = modal.ConventionId,
         Name = modal.Name,
         StartDate = modal.StartDate.ToString("dd-MM-yyyy HH:mm"),
         EndDate = modal.EndDate.ToString("dd-MM-yyyy HH:mm"),
         Booking = GetConventionBookingTarget(modal.ConventionId),
         Donation = GetFundRaisingTarget(modal.ConventionId),
         GSBAmount = GetGSBAountTarget(modal.ConventionId),
         Events = GetEventsTarget(modal.ConventionId),
         IsResourceAttached = modal.IsFileAttached,
         ProfilePic = modal.FileResource == null ? Url.Content("~/Content/Images/Common/office_convention_avatar.png") : Url.Content(modal.FileResource.path)
     }).Skip((pageNo - 1) * pageSize).Take(pageSize).ToList();
     return Json(new
     {
         totalRecord = totalRecord,
         currentPage = pageNo,
         pageSize = pageSize,
         conventions = filteredConventions
     });
 }