public GeneralListingViewModel(Listing ln) : base(ln)
        {
            var gQ = from l in db.GeneralListings.Include("Listing.Category")
                     where l.ListingId == ln.ListingId
                     select l;
            GeneralListing listing = gQ.FirstOrDefault();

            Brand     = listing.Brand;
            Condition = listing.Condition;
        }
Example #2
0
        public override void EditListing()
        {
            string user = HttpContext.Current.User.Identity.GetUserId();
            var    lnQ  = from c in db.GeneralListings.Include("Listing")
                          where c.ListingId == this.ListingId && c.Listing.OwnerId == user
                          select c;
            GeneralListing ln = lnQ.FirstOrDefault();

            ln.Listing.Title       = Title;
            ln.Listing.Description = Description;
            ln.Listing.Price       = Price;
            ln.Listing.Town        = Town;
            ln.Listing.Status      = Status;
            ln.Listing.Updated     = DateTime.Now;
            ln.Brand     = Brand;
            ln.Condition = Condition;
            // other changed properties
            db.SaveChanges();
        }
Example #3
0
    private void CreateListings()
    {
        List <CardPlayerData> generals = new List <CardPlayerData>();

        for (int i = 0; i < _deckBuilder.allGenerals.Count; i++)
        {
            if (_deckBuilder.allGenerals[i].faction == faction)
            {
                generals.Add(_deckBuilder.allGenerals[i]);
            }
        }

        for (int i = 0; i < generals.Count; i++)
        {
            GameObject listing = Instantiate(template.gameObject) as GameObject;
            listing.transform.SetParent(listingsContainer, false);
            listing.SetActive(true);
            GeneralListing general = listing.GetComponent <GeneralListing>();
            generalListings.Add(general);
            general.Initialize(_deckBuilder, generals[i]);
        }
    }
Example #4
0
        public override int AddNewListing()
        {
            GeneralListing ln = new GeneralListing();
            Listing        l  = new Listing();
            //moths to expire this ad
            int months = (Category.ExpiresIn > 0) ? Category.ExpiresIn : 3;

            ln.Listing             = l;
            ln.Listing.Title       = Title;
            ln.Listing.CategoryId  = CategoryId;
            ln.Listing.Description = Description;
            ln.Listing.Price       = Price;
            ln.Listing.Town        = Town;
            ln.Listing.Created     = DateTime.Now;
            ln.Listing.Updated     = DateTime.Now;
            ln.Listing.Status      = "live";
            ln.Listing.OwnerId     = HttpContext.Current.User.Identity.GetUserId();
            ln.Listing.Expires     = DateTime.Now.AddMonths(months);
            ln.Condition           = Condition;
            ln.Brand = Brand;
            db.GeneralListings.Add(ln);
            db.SaveChanges();
            return(ln.Listing.ListingId);
        }