/*
         * The UploadFiles method coordinates saving a file to Azure BLOB storage with updating the database through a Model class.
         */
        public ActionResult UploadFiles(string EventID)
        {
            bool   isSaved     = true;
            string savedStatus = string.Empty;

            for (int idx = 0; idx < Request.Files.Count; idx++)
            {
                HttpPostedFileBase file       = (HttpPostedFileBase)Request.Files[idx];
                Stream             fileStream = file.InputStream;
                string             fileName   = getFileName(file.FileName);
                Models.EventData   eventData  = new Models.EventData();
                savedStatus = eventData.AddAttachmentItem(EventID, EventID + "/" + fileName);

                if (savedStatus.StartsWith("Point8020.Success"))
                {
                    savedStatus = SaveFileToAzure(fileStream, file.ContentType, EventID + "/" + fileName);
                    if (savedStatus != "Point8020.Success")
                    {
                        isSaved = false;
                    }
                }
                else
                {
                    isSaved = false;
                }
            }
            if (isSaved == true)
            {
                return(RedirectToAction("Events", "Home", new { SPHostUrl = SharePointContext.GetSPHostUrl(HttpContext.Request).AbsoluteUri }));
            }
            else
            {
                return(RedirectToAction("TrappedError", "Home", new { ErrorMessage = "File could not be saved: Error Code is: " + savedStatus, SPHostUrl = SharePointContext.GetSPHostUrl(HttpContext.Request).AbsoluteUri }));
            }
        }
        public ActionResult CreateAttachmentItem(string eventID, string url)
        {
            Models.EventData eventData = new Models.EventData();
            string           saved     = eventData.AddAttachmentItem(eventID, url);

            if (saved.StartsWith("Point8020.Error"))
            {
                return(RedirectToAction("TrappedError", "Home", new { ErrorMessage = "Item could not be saved: Error Code is: " + saved, SPHostUrl = SharePointContext.GetSPHostUrl(HttpContext.Request).AbsoluteUri }));
            }
            else
            {
                return(RedirectToAction("Attachments", "Home", new { EventID = eventID, SPHostUrl = SharePointContext.GetSPHostUrl(HttpContext.Request).AbsoluteUri }));
            }
        }