Beispiel #1
0
        public ActionResult Create([Bind(Include = "IsExternal,Email,Name,Image,ExternalLink,DisplayInHomePage")] FeaturedPartner featuredPartner)
        {
            if (ModelState.IsValid)
            {
                featuredPartner.Created  = DateTime.Now;
                featuredPartner.Modified = DateTime.Now;

                if (featuredPartner.IsExternal.HasValue && featuredPartner.IsExternal.Value)
                {
                    string imagePath = Server.MapPath(Global.FeaturedPartnerImages + string.Format("FeaturedPartners_{0}_{1}.jpg", featuredPartner.FeaturedPartnerId, DateTime.Now.ToString("ddMMyyss")));
                    featuredPartner.Image = ImageHelper.UploadImage(Request.Files["Image"], Global.FeaturedPartnerImages, imagePath, false);
                }
                else
                {
                    var user = db.AspNetUsers.FirstOrDefault(x => x.Email.Equals(featuredPartner.Email, StringComparison.InvariantCultureIgnoreCase));
                    if (user == null)
                    {
                        ModelState.AddModelError("", "User not found.");
                        return(View(featuredPartner));
                    }

                    featuredPartner.PartnerId = user.Id;
                }

                db.FeaturedPartners.Add(featuredPartner);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(featuredPartner));
        }
        public async Task <bool> Subscribe(string email)
        {
            if (new EmailAddressAttribute().IsValid(email))
            {
                if (!db.Subscribers.Any(x => x.Email.Equals(email, StringComparison.InvariantCultureIgnoreCase)))
                {
                    db.Subscribers.Add(new Subscriber()
                    {
                        Email    = email,
                        Created  = DateTime.Now,
                        IsActive = true,
                        Modified = DateTime.Now
                    });

                    db.SaveChanges();
                    string emailMessage = "Thanks for registering interest to the <a href=\"http://www.artbrowserapp.com\">ArtBrowser</a> app<br/><br/>" + Global.MailSignature;
                    // send email to admins
                    IdentityMessage message = new IdentityMessage();
                    message.Destination = email;
                    message.Subject     = "Thanks for registering interest to the ArtBrowser app!";
                    message.Body        = emailMessage;

                    EmailService mailService = new EmailService();
                    await mailService.SendAsync(message);
                }

                return(true);
            }
            else
            {
                ModelState.AddModelError("", "Invalid Email ID.");
                return(false);
            }
        }
        public ActionResult Create([Bind(Include = "Key,Value")] Configuration configuration)
        {
            if (ModelState.IsValid)
            {
                db.Configurations.Add(configuration);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(configuration));
        }
        public ActionResult UpdateUser(string id, string status)
        {
            var user = db.AspNetUsers.FirstOrDefault(x => x.Id.Equals(id, StringComparison.InvariantCultureIgnoreCase));

            if (user != null)
            {
                user.ApprovalStatus = status;
                db.SaveChanges();
            }

            return(RedirectToAction("PendingUsers"));
        }
        public ActionResult Create([Bind(Include = "Name")] Category category)
        {
            if (ModelState.IsValid)
            {
                category.Created  = DateTime.Now;
                category.Modified = DateTime.Now;
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Beispiel #6
0
        public ActionResult Create([Bind(Include = "Name")] Location location)
        {
            if (ModelState.IsValid)
            {
                location.Created  = DateTime.Now;
                location.Modified = DateTime.Now;
                db.Locations.Add(location);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(location));
        }
Beispiel #7
0
        public async static Task <IdentityResult> AddUserToRole(this ApplicationUserManager manager, ApplicationUser user, string role)
        {
            ArtBrowserDBContext db   = new ArtBrowserDBContext();
            UserType            Role = ((UserType)Enum.Parse(typeof(UserType), role));

            switch (Role)
            {
            case UserType.Artist:
                db.Artists.Add(new Artist()
                {
                    User_ID = user.Id
                });
                break;

            case UserType.Institution:
                db.Institutions.Add(new Institution()
                {
                    User_ID = user.Id
                });
                break;
            }

            db.SaveChanges();
            return(await manager.AddToRoleAsync(user.Id, role));
        }
Beispiel #8
0
        public ActionResult Create([Bind(Include = "Title,Description")] Announcement announcement, string status)
        {
            if (ModelState.IsValid)
            {
                var    identity = ((ClaimsIdentity)User.Identity);
                string userid   = identity.GetClaimValue(ClaimTypes.NameIdentifier);

                StatusType annoucementStatus = status == Sumbit ? StatusType.PendingApproval : StatusType.Draft;
                announcement.Status   = annoucementStatus.GetEnumDescription();
                announcement.User_ID  = userid;
                announcement.Created  = DateTime.Now;
                announcement.Modified = DateTime.Now;

                db.Announcements.Add(announcement);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(announcement));
        }
        public ActionResult Create([Bind(Include = "EventId,Title,Location,Address,Statement,StartDate,EndDate,Created,Modified,ImagePath,DisplayInHomePage,IsExternal,ExternalLink")] Event @event)
        {
            if (ModelState.IsValid)
            {
                TryUpdateModel(@event);

                @event.Created  = DateTime.Now;
                @event.Modified = DateTime.Now;

                string imagePath = Server.MapPath(Global.EventImages + string.Format("Event_{0}_{1}.jpg", @event.EventId, DateTime.Now.ToString("ddMMyyss")));
                @event.ImagePath = ImageHelper.UploadImage(Request.Files["ImagePath"], Global.EventImages, imagePath, false);

                db.Events.Add(@event);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(@event));
        }
Beispiel #10
0
        public ActionResult Create([Bind(Include = "Title,Category_ID,Subject,Price,Location_ID,Size,Medium,Statement,Status,Cover_Pic_Path,Art_Images")] ArtsViewModel model)
        {
            if (ModelState.IsValid)
            {
                Art item = new Art();
                TryUpdateModel(item);

                var    identity = ((ClaimsIdentity)User.Identity);
                string userid   = identity.GetClaimValue(ClaimTypes.NameIdentifier);
                item.User_ID  = userid;
                item.Status   = StatusType.Draft.ToString();
                item.Created  = DateTime.Now;
                item.Modified = DateTime.Now;
                db.Arts.Add(item);
                db.SaveChanges();

                string imagePath = Server.MapPath(Global.ArtImages + string.Format("Art_Cover_{0}_{1}.jpg", item.Art_ID, DateTime.Now.ToString("ddMMyyss")));
                item.Cover_Pic_Path = ImageHelper.UploadImage(Request.Files["Cover_Pic_Path"], Global.ArtImages, imagePath, false);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
        public ActionResult Create([Bind(Include = "ExhibitionId,UserId,Title,ImagePath,Location,Address,Statement,StartDate,EndDate")] Exhibition exhibition)
        {
            if (ModelState.IsValid)
            {
                TryUpdateModel(exhibition);

                var    identity = ((ClaimsIdentity)User.Identity);
                string userid   = identity.GetClaimValue(ClaimTypes.NameIdentifier);
                exhibition.UserId   = userid;
                exhibition.Created  = DateTime.Now;
                exhibition.Modified = DateTime.Now;

                string imagePath = Server.MapPath(Global.ExhibitionImages + string.Format("Exhibition_{0}_{1}.jpg", exhibition.ExhibitionId, DateTime.Now.ToString("ddMMyyss")));
                exhibition.ImagePath = ImageHelper.UploadImage(Request.Files["ImagePath"], Global.ExhibitionImages, imagePath, false);

                db.Exhibitions.Add(exhibition);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(exhibition));
        }
        public ActionResult EditArtistProfile(Artist model)
        {
            var    identity = ((ClaimsIdentity)User.Identity);
            string userid   = identity.GetClaimValue(ClaimTypes.NameIdentifier);
            Artist artist   = db.Artists.FirstOrDefault(x => x.Artist_ID == model.Artist_ID);

            if (ModelState.IsValid && artist != null)
            {
                TryUpdateModel(artist);
                db.SaveChanges();

                string   role = identity.GetClaimValue(ClaimTypes.Role);
                UserType Role = ((UserType)Enum.Parse(typeof(UserType), role));

                return(RedirectToAction(Role == UserType.Administrator ? "Artists" : "Index"));
            }
            else
            {
                return(View(model));
            }
        }