public ActionResult Edit([Bind(Include = "Email,FirstName,LastName,City,State,Zip")] Member member) { if (ModelState.IsValid) { db.Entry(member).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(member)); }
public ActionResult Edit([Bind(Include = "Id,Style,Brewer,BeerName,Abv,Description")] Beer beer) { if (ModelState.IsValid) { db.Entry(beer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(beer)); }
public ActionResult Edit([Bind(Include = "Id,MemberId,CellarName")] Cellar cellar) { if (ModelState.IsValid) { db.Entry(cellar).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MemberId = new SelectList(db.Members, "Id", "Email", cellar.MemberId); return(View(cellar)); }
public ActionResult Edit([Bind(Include = "Id,SendingMemberId,ReceivingMemberId,SendingBeerId,ReceiverBeerId,IsApproved,SendingComments,ReceivingComments")] Trade trade) { if (ModelState.IsValid) {//var trade = new trade db.Entry(trade).State = EntityState.Modified; if (trade.IsApproved.HasValue && trade.IsApproved.Value) { Cellar offertradecellar = db.Cellars.Find(trade.SendingMemberId); Cellar recievingtradecellar = db.Cellars.Find(trade.ReceivingMemberId); Beer offeretradebeer = db.Beers.Find(trade.SendingBeerId); Beer recievingtradebeer = db.Beers.Find(trade.ReceiverBeerId); offertradecellar.Beers.Remove(offeretradebeer); offertradecellar.Beers.Add(recievingtradebeer); recievingtradecellar.Beers.Add(offeretradebeer); recievingtradecellar.Beers.Remove(recievingtradebeer); var recievingmember = recievingtradecellar.Member; // var recievingembername = recievingtradecellar.CellarName; var sendingmember = offertradecellar.Member; // var sendingmembername = recievingtradecellar.CellarName, var bodyTemplate = "<p>Hi {0}</p><p>Your CraftX trade has been accepted,Enjoy!</p>"; var recievingbody = string.Format(bodyTemplate, recievingmember.FirstName); var sendingbody = string.Format(bodyTemplate, sendingmember.FirstName); MessagSender.SendEmail(recievingmember.Email, "CraftX Acepted Trade Offer", recievingbody); MessagSender.SendEmail(sendingmember.Email, "Acepted Trade Offer", sendingbody); } db.SaveChanges(); return(RedirectToAction("Index")); } else { IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors); var error = string.Join("\n", allErrors.Select(e => e.ErrorMessage)); } ViewBag.ReceiverBeerId = new SelectList(db.Beers, "Id", "Style", trade.ReceiverBeerId); ViewBag.SendingBeerId = new SelectList(db.Beers, "Id", "Style", trade.SendingBeerId); ViewBag.ReceivingMemberId = new SelectList(db.Cellars, "Id", "MemberId", trade.ReceivingMemberId); ViewBag.SendingMemberId = new SelectList(db.Cellars, "Id", "MemberId", trade.SendingMemberId); return(View(trade)); }