public override void EditListing() { string user = HttpContext.Current.User.Identity.GetUserId(); var carQ = from c in db.Motas.Include("Listing") where c.ListingId == this.ListingId && c.Listing.OwnerId == user select c; Mota car = carQ.FirstOrDefault(); car.Listing.Title = Title; car.Listing.Description = Description; car.Listing.Price = Price; car.Listing.Town = Town; car.Listing.Updated = DateTime.Now; car.Listing.Status = Status; car.Make = Make; car.CarModel = CarModel; car.BodyType = BodyType; car.Condition = Condition; car.EngineSize = EngineSize; car.FuelType = FuelType; car.Mileage = Mileage; car.Transmission = Transmission; car.Year = Year; db.SaveChanges(); }
public override int AddNewListing() { Mota car = new Mota(); Listing listing = new Listing(); //moths to expire this ad int months = (Category.ExpiresIn > 0) ? Category.ExpiresIn : 3; car.Listing = listing; car.Listing.Title = Title; car.Listing.CategoryId = CategoryId; car.Listing.Description = Description; car.Listing.Price = Price; car.Listing.Town = Town; car.Listing.Created = DateTime.Now; car.Listing.Updated = DateTime.Now; car.Listing.Status = "live"; car.Listing.OwnerId = HttpContext.Current.User.Identity.GetUserId(); car.Listing.Expires = DateTime.Now.AddMonths(months); car.BodyType = BodyType; car.CarModel = CarModel; car.Condition = Condition; car.EngineSize = EngineSize; car.FuelType = FuelType; car.Make = Make; car.Mileage = Mileage; car.Transmission = Transmission; car.Year = Year; db.Motas.Add(car); db.SaveChanges(); return(car.Listing.ListingId); }
public AutosViewModel(Listing ln) : base(ln) { var motaQ = from l in db.Motas.Include("Listing.Category") where l.ListingId == ln.ListingId select l; Mota car = motaQ.FirstOrDefault(); Make = car.Make; CarModel = car.CarModel; Year = car.Year; Mileage = car.Mileage; FuelType = car.FuelType; Transmission = car.Transmission; Condition = car.Condition; BodyType = car.BodyType; EngineSize = car.EngineSize; }