public void Save(ProgramViewSD model)
        {
            try
            {
                if (model.ImageFile != null && model.ImageFile.ContentLength > 0)
                {
                    var fileName = DataAccess.Utilities.GenerateUniqueID() + Path.GetExtension(model.ImageFile.FileName);

                    try
                    {
                        var result = AwsHelpers.UploadImage(fileName, model.ImageFile);

                        model.Program.Image = fileName;
                    }
                    catch (Exception ex)
                    {
                        string s = string.Empty;
                    }
                }
            }
            catch (Exception ex)
            {
                string s = string.Empty;
            }

            using (var projectProvider = new ProgramProvider())
            {
                if (model.New)
                {
                    try
                    {
                        projectProvider.Insert(model.Program);
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.ContainsValue("PRIMARY"))
                        {
                            projectProvider.Update(model.Program);
                        }
                    }
                }
                else
                {
                    projectProvider.Update(model.Program);
                }
            }
        }
        public ActionResult Edit(ProgramViewSD item)
        {
            if (ModelState.IsValid)
            {
                if (item.ImageFile != null && item.ImageFile.ContentLength > 0)
                {
                    var fileName = DataAccess.Utilities.GenerateUniqueID() + Path.GetExtension(item.ImageFile.FileName);

                    try
                    {
                        var result = AwsHelpers.UploadImage(fileName, item.ImageFile);

                        item.Program.Image = fileName;
                    }
                    catch (Exception ex)
                    {
                        AlertMessage = "Your program has been saved successfully, but there was a problem uploading your image.  Please contact our support if you continue to have problems.";
                    }
                }

                using (var provider = new ProgramProvider())
                {
                    provider.Update(item.Program);
                }

                return Redirect("/Site/ViewProgram/" + item.Program.Id);
            }

            return View(DefaultViews.CreateEdit, item);
        }
        public ActionResult SaveStatus(ProgramViewSD model, string status)
        {
            if (!string.IsNullOrWhiteSpace(status))
            {
                model.Program.Status = status;
            }

            Save(model);

            AlertMessage = "Your program has been saved...";
            AlertMessageType = AlertMessageTypes.Success;

            return RedirectToAction("Index", "Dashboard");
        }
        public ActionResult Create(string sponsorId)
        {
            var sponsor = !string.IsNullOrEmpty(sponsorId) ? ApplicationCache.Instance.Sponsors.FirstOrDefault(x => x.Id.Equals(sponsorId)) : null;
            var organization = sponsor != null ? sponsor.Name : "";
            var website = sponsor != null ? sponsor.Website : "";

            var item = new ProgramViewSD() { New = true, Program = new ProgramSD
            {
                Id = DataAccess.Utilities.GenerateUniqueID(), 
                SponsorId = sponsorId, 
                CreatedBy = SessionVariables.CurrentUser.Id, 
                DoesCost = false, 
                Visibility = ProgramVisibility.Public, 
                Status = ProgramStatus.Draft, 
                LocationType = ProgramLocationTypes.Items.First(), 
                SponsoringOrganization = organization, 
                SponsoringOrganizationWebsite = website
            } };

            return View(DefaultViews.CreateEdit, item);
        }