Ejemplo n.º 1
0
 public ActionResult Create(Offers newOffer, string Currency, string TagsString)
 {
     if (User.Identity.Name != "")
     {
         WWO = new WorkWithOffers(Server);
         string defaultImage = null;
         newOffer.Photo1URL = imageURLs.Count > 0 ? imageURLs.Dequeue() : defaultImage;
         newOffer.Photo2URL = imageURLs.Count > 0 ? imageURLs.Dequeue() : defaultImage;
         newOffer.Photo3URL = imageURLs.Count > 0 ? imageURLs.Dequeue() : defaultImage;
         newOffer.Photo4URL = imageURLs.Count > 0 ? imageURLs.Dequeue() : defaultImage;
         newOffer.Price     = newOffer.Price + ' ' + Currency;
         imageURLs.Clear();
         if ((newOffer.Name == "") || (newOffer.Name == null))
         {
             if (newOffer.OfferID != null)
             {
                 WWO.DeleteOfferTags(newOffer.OfferID);
                 WWO.AddTagsToOffer(newOffer.OfferID, TagsString);
             }
             WorkWithTags WWT = new WorkWithTags();
             ViewBag.Tags = WWT.GetTagsNamesList();
             return(View(newOffer));
         }
         string OfferID = WWO.AndNewOrModify(newOffer, User.Identity.Name);
         WWO.DeleteOfferTags(OfferID);
         WWO.AddTagsToOffer(OfferID, TagsString);
         WWO.CreateIndex(newOffer);
         imageURLs.Clear();
         return(RedirectToAction("TabClick", "Home", new { TabID = 3 }));
     }
     else
     {
         return(RedirectToAction("AccessDenied", "AccessDenied"));
     }
 }
Ejemplo n.º 2
0
        public ActionResult Create(string OfferID)
        {
            Offers Offer;

            if (OfferID == null)
            {
                Offer = new Offers();
            }
            else
            {
                WorkWithOffers WWO = new WorkWithOffers(Server);
                Offer            = WWO.GetOfferByID(OfferID);
                ViewBag.Currency = WWO.GetAndDeleteCurrency(Offer);

                imageURLs.Clear();
                if (Offer.Photo1URL != null)
                {
                    imageURLs.Enqueue(Offer.Photo1URL);
                }
                if (Offer.Photo2URL != null)
                {
                    imageURLs.Enqueue(Offer.Photo2URL);
                }
                if (Offer.Photo3URL != null)
                {
                    imageURLs.Enqueue(Offer.Photo3URL);
                }
                if (Offer.Photo4URL != null)
                {
                    imageURLs.Enqueue(Offer.Photo4URL);
                }
            }

            WorkWithTags WWT = new WorkWithTags();

            ViewBag.Tags = WWT.GetTagsNamesList();

            if (ViewBag.Currency == null)
            {
                ViewBag.Currency = "USA";
            }

            if (User.Identity.Name == "")
            {
                return(RedirectToAction("AccessDenied", "AccessDenied"));
            }
            else
            {
                return(View(Offer));
            }
        }
        public ActionResult Index()
        {
            IndexViewData = (IndexDataModel)Session["IndexData"];
            WorkWithTags   WWT = new WorkWithTags();
            WorkWithOffers WWO = new WorkWithOffers(Server);
            WorkWithUsers  WWU = new WorkWithUsers();

            if (IndexViewData == null)
            {
                IndexViewData            = new IndexDataModel();
                IndexViewData.ShowString = "NewOffers";
                IndexViewData.NewOffers  = WWO.GetNewOffers();
            }

            IndexViewData.WeightTags = WWT.GetWeightTags();
            ViewBag.ViewData         = IndexViewData;
            Session["IndexData"]     = IndexViewData;

            if (User.Identity.Name != "")
            {
                if (WWU.GetUserRole(IdentityExtensions.GetUserId(User.Identity)) == "Banned")
                {
                    return(RedirectToAction("UserBanned", "AccessDenied"));
                }
            }

            if (IndexViewData.ShowString == "NewOffers")
            {
                IndexViewData.NewOffers = WWO.GetNewOffers();
            }
            if (IndexViewData.ShowString == "TopUsers")
            {
                IndexViewData.TopUsers = WWU.GetTopUsers();
            }
            if (IndexViewData.ShowString == "TopOffers")
            {
                IndexViewData.NewOffers = WWO.GetTopOffers();
            }

            return(View());
        }