public ActionResult Create(Giftee giftee) { // TODO: Add insert logic here DbContext.Giftees.Add(giftee); DbContext.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(Giftee giftee) { var giftGetter = DbContext.Giftees.Where(g => g.Id == giftee.Id).FirstOrDefault(); DbContext.Giftees.Remove(giftGetter); DbContext.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Giftee giftee) { var GifteeInDB = DbContext.Giftees.Single(g => g.Id == giftee.Id); GifteeInDB.LengthOfRelationshipId = giftee.LengthOfRelationshipId; GifteeInDB.LengthOfRelationship = giftee.LengthOfRelationship; GifteeInDB.TypeOfRelationship = giftee.TypeOfRelationship; GifteeInDB.TypeOfRelationshipId = giftee.TypeOfRelationshipId; GifteeInDB.Age = giftee.Age; GifteeInDB.FirstName = giftee.FirstName; GifteeInDB.LastName = giftee.LastName; GifteeInDB.CategoryId = giftee.CategoryId; GifteeInDB.Category = giftee.Category; DbContext.SaveChanges(); return(RedirectToAction("Index")); }
static void Main(string[] args) { var gift = new Gift("mixie"); var gift1 = new Gift("washing machine"); var giftee = new Giftee(1, "Ramu"); var gifter = new Gifter("Sabu"); gifter.SendGift(gift, giftee); gifter.SendGift(gift1, giftee); var res = giftee.GetAllRecievedGifts(); foreach (var g in res) { Console.WriteLine(g); } Console.WriteLine("Hello World!"); }
// GET: Giftees/Create public ActionResult Create() { Giftee giftee = new Giftee(); return(View(giftee)); }