public async Task <IActionResult> Edit(int id, [Bind("Id,女性id,場所,費用,時間帯,備考")] Dating dating) { if (id != dating.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dating); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DatingExists(dating.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["女性id"] = new SelectList(_context.Woman, "Id", "仮名", dating.女性id); return(View(dating)); }
public override int AddNewListing() { Dating ln = new Dating(); 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.Age = Age; ln.Sex = Sex; ln.Drink = Drink; ln.Ethnicity = Ethnicity; ln.Height = Height; ln.Interests = Interests; ln.Nationality = Nationality; ln.Occupation = Occupation; ln.Religion = Religion; ln.Smoke = Smoke; ln.Type = Type; db.Dates.Add(ln); db.SaveChanges(); return(ln.Listing.ListingId); }
public override void EditListing() { string user = HttpContext.Current.User.Identity.GetUserId(); var lnQ = from c in db.Dates.Include("Listing") where c.ListingId == this.ListingId && c.Listing.OwnerId == user select c; Dating 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.Age = Age; ln.Drink = Drink; ln.Ethnicity = Ethnicity; ln.Height = Height; ln.Interests = Interests; ln.Nationality = Nationality; ln.Occupation = Occupation; ln.Religion = Religion; ln.Sex = Sex; ln.Smoke = Smoke; ln.Type = Type; // other changed properties db.SaveChanges(); }
public ActionResult DeleteConfirmed(int id) { Dating dating = db.Datings.Find(id); db.Datings.Remove(dating); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create([Bind("Id,女性id,場所,費用,時間帯,備考")] Dating dating) { if (ModelState.IsValid) { _context.Add(dating); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["女性id"] = new SelectList(_context.Woman, "Id", "仮名", dating.女性id); return(View(dating)); }
// GET: Datings/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Dating dating = db.Datings.Find(id); if (dating == null) { return(HttpNotFound()); } return(View(dating)); }
// GET: Datings/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Dating dating = db.Datings.Find(id); if (dating == null) { return(HttpNotFound()); } ViewBag.PersonalDetailsID = new SelectList(db.PersonalDetails, "PersonalDetailsID", "FirstName", dating.PersonalDetailsID); ViewBag.SexID = new SelectList(db.Sexes, "SexID", "Name", dating.SexID); return(View(dating)); }
public ActionResult Edit([Bind(Include = "PersonalDetailsID,FromAge,ToAge,SexID")] Dating dating) { if (ModelState.IsValid) { string currentUserId = User.Identity.GetUserId(); PersonalDetails person = db.PersonalDetails.Where(p => p.AspNetUserId.Equals(currentUserId)).First(); dating.PersonalDetailsID = person.PersonalDetailsID; db.Datings.Add(dating); db.Entry(dating).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "PesonalDetail_DoInFlight_YesNoAnswer")); } ViewBag.PersonalDetailsID = new SelectList(db.PersonalDetails, "PersonalDetailsID", "FirstName", dating.PersonalDetailsID); ViewBag.SexID = new SelectList(db.Sexes, "SexID", "Name", dating.SexID); return(View(dating)); }
public DatingViewModel(Listing ls) : base(ls) { var compQ = from l in db.Dates.Include("Listing.Category") where l.ListingId == ls.ListingId select l; Dating ln = compQ.FirstOrDefault(); Type = ln.Type; Age = ln.Age; Sex = ln.Sex; Interests = ln.Interests; Religion = ln.Religion; Occupation = ln.Occupation; Nationality = ln.Nationality; Weight = ln.Weight; Height = ln.Height; Ethnicity = ln.Ethnicity; Smoke = ln.Smoke; Drink = ln.Drink; }