コード例 #1
0
        public ActionResult DeleteConfirmed(int id, int PublisherId)
        {
            Comment comment = db.Comments.Find(id);

            db.Comments.Remove(comment);
            db.SaveChanges();
            return(RedirectToAction("GetPublisherPublicProfile", "Home", new { id = PublisherId }));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "CountryId,Name,isActive")] Country country)
        {
            if (ModelState.IsValid)
            {
                db.Countries.Add(country);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(country));
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "PublisherPicId,PublisherId,ImageUrl,UploadedOn,UploadedByUserId,Order")] PublisherPic publisherPic)
        {
            if (ModelState.IsValid)
            {
                db.PublisherPics.Add(publisherPic);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PublisherId = new SelectList(db.Publishers, "PublisherId", "Name", publisherPic.PublisherId);
            return(View(publisherPic));
        }
コード例 #4
0
        public ActionResult Create([Bind(Include = "StateId,Name,isActive,CountryId")] State state)
        {
            if (ModelState.IsValid)
            {
                db.States.Add(state);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CountryId = new SelectList(db.Countries, "CountryId", "Name", state.CountryId);
            return(View(state));
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "PublisherId,Name,IdNumber,IdImageUrl,Address,Telephone,Email,ProfileImageUrl,PricePerService,DescriptionService,IsActive,StateId,CountryId")] Publisher publisher)
        {
            if (ModelState.IsValid)
            {
                db.Publishers.Add(publisher);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CountryId = new SelectList(db.Countries, "CountryId", "Name", publisher.CountryId);
            ViewBag.StateId   = new SelectList(db.States, "StateId", "Name", publisher.StateId);
            return(View(publisher));
        }
コード例 #6
0
        public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model, string returnUrl)
        {
            string provider       = null;
            string providerUserId = null;

            if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId))
            {
                return(RedirectToAction("Manage"));
            }

            if (ModelState.IsValid)
            {
                // Insert a new user into the database
                using (PhotoBookContext db = new PhotoBookContext())
                {
                    User user = db.User.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower());
                    // Check if user already exists
                    if (user == null)
                    {
                        // Insert name into the profile table
                        db.User.Add(new User {
                            UserName = model.UserName
                        });
                        db.SaveChanges();

                        OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName);
                        OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false);

                        return(RedirectToLocal(returnUrl));
                    }
                    else
                    {
                        ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name.");
                    }
                }
            }

            ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName;
            ViewBag.ReturnUrl           = returnUrl;
            return(View(model));
        }