示例#1
0
        public ActionResult Update(Pub pubUpdate)
        {
            var returnedPub = PubDAO.Search(UserSession.ReturnPubId(null));

            if (returnedPub == null)
            {
                return(RedirectToAction("Logout", "User"));
            }

            // Set the remaining properties of the model
            returnedPub.Name           = pubUpdate.Name ?? returnedPub.Name;
            returnedPub.FoundationDate = pubUpdate.FoundationDate == null ? returnedPub.FoundationDate : pubUpdate.FoundationDate;
            returnedPub.Address        = pubUpdate.Address ?? returnedPub.Address;
            returnedPub.City           = pubUpdate.City ?? returnedPub.City;
            returnedPub.State          = pubUpdate.State ?? returnedPub.State;

            // Get the coordinates of the bar location that the user has given
            Tuple <double, double> tuple =
                GoogleGeoLocation.GetCoordinates(returnedPub.Address, returnedPub.City, returnedPub.State);

            returnedPub.Lat = tuple.Item1;
            returnedPub.Lng = tuple.Item2;

            if (PubDAO.Update(returnedPub) != true)
            {
                ModelState.AddModelError("", "Error - Check information and try again");
                return(View("Account"));
            }

            return(RedirectToAction("Account"));
        }
示例#2
0
        public ActionResult Rate(int id)
        {
            var pub = PubDAO.Search(id);
            var rating = RatingDAO.SearchByPersonAndPubId(UserSession.ReturnPersonId(null), pub.Id);

            if (rating == null)
            {
                rating = new Rating
                {
                    PersonId = UserSession.ReturnPersonId(null),
                    PubId = pub.Id
                };
                if (RatingDAO.Insert(rating) != null)
                {
                    pub.Rating = pub.Rating + 1;
                    PubDAO.Update(pub);
                }
            }
            else
            {
                if (RatingDAO.Delete(rating) == true)
                {
                    pub.Rating = pub.Rating - 1;
                    PubDAO.Update(pub);
                }
            }
            return RedirectToAction("Pub", new { id });
        }
示例#3
0
        public ActionResult Update(Pub pubUpdate)
        {
            var pub = PubDAO.Search(UserSession.ReturnPubId(null));

            pubUpdate.Rating           = pub.Rating;
            pubUpdate.RegistrationDate = pub.RegistrationDate;
            pubUpdate.UserType         = pub.UserType;
            pubUpdate.State            = pub.State;
            pubUpdate.PhotoUrl         = pub.PhotoUrl;
            pubUpdate.Login            = pub.Login;
            pubUpdate.Id = pub.Id;
            if (pubUpdate.Password == null)
            {
                pubUpdate.Password = pub.Password;
            }

            Tuple <double, double> tuple = GoogleGeoLocation.GetCoordinates(pubUpdate.Address, pubUpdate.State);

            pubUpdate.Lat = tuple.Item1;
            pubUpdate.Lng = tuple.Item2;

            if (PubDAO.Update(pubUpdate) == true)
            {
                return(RedirectToAction("Dashboard"));
            }
            else
            {
                ViewBags();
                ModelState.AddModelError("", "Error - Check information and try again");
                return(View("Account", pub));
            }
        }
示例#4
0
        public ActionResult UpdateImg(HttpPostedFileBase upImage)
        {
            var pub = PubDAO.Search(UserSession.ReturnPubId(null));

            if (upImage != null)
            {
                pub.PhotoUrl  = ImageHandler.HttpPostedFileBaseToByteArray(upImage);
                pub.PhotoType = upImage.ContentType;
                PubDAO.Update(pub);

                return(RedirectToAction("Account", "Pub"));
            }
            else
            {
                ViewBags();
                ModelState.AddModelError("", "Error - Image dont work");
                return(View("Account", pub));
            }
        }
示例#5
0
        public ActionResult UpdateProfile(HttpPostedFileBase upImage)
        {
            if (upImage == null)
            {
                ModelState.AddModelError("", "Error - Image dont work");
                return(View("Account"));
            }

            var pub = PubDAO.Search(UserSession.ReturnPubId(null));

            pub.Photo     = ImageHandler.HttpPostedFileBaseToByteArray(upImage);
            pub.PhotoType = upImage.ContentType;

            if (PubDAO.Update(pub) != true)
            {
                ModelState.AddModelError("", "Error - Database update image error!");
                return(View("Account"));
            }
            return(RedirectToAction("Dashboard"));
        }