Example #1
0
        public IActionResult UpdateWedding(WeddingViewModel model)
        {
            Wedding UpdatingWedding = _context.Weddings.Where(w => w.WeddingId == model.WeddingId).FirstOrDefault();

            if (UpdatingWedding != null)
            {
                UpdatingWedding.Bride   = model.Bride;
                UpdatingWedding.Groom   = model.Groom;
                UpdatingWedding.Date    = model.Date;
                UpdatingWedding.UserId  = (int)HttpContext.Session.GetInt32("CurrUser");
                UpdatingWedding.Address = model.Address;

                _context.Update(UpdatingWedding);
                _context.SaveChanges();
                return(RedirectToAction("Wedding", new { Id = UpdatingWedding.WeddingId }));
            }
            return(RedirectToAction("Wedding", model));
        }