Esempio n. 1
0
        public bool InsertWedding(Wedding wedding, int userid)
        {
            var user = Users.FirstOrDefault(u => u.UserId == userid);

            if (user != null)
            {
                wedding.UserId = user.UserId;

                wedding.GuestList = new List <GuestWedding>();
                wedding.GuestList.Add(new GuestWedding()
                {
                    WeddingId = wedding.WeddingId,
                    UserId    = userid
                });

                Add(wedding);
                SaveChanges();


                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        public IActionResult CreateWedding(RegisterWeddingModel myWedding)
        {
            ViewBag.Errors = new List <string>();

            if (ModelState.IsValid)
            {
                System.Console.WriteLine("WEDDING WAS VALID!");
                System.Console.WriteLine("WEDDING WAS VALID!");
                System.Console.WriteLine("WEDDING WAS VALID!");
                System.Console.WriteLine("WEDDING WAS VALID!");
                if (myWedding.Date > DateTime.Now)
                {
                    System.Console.WriteLine("WEDDING WAS VALID!");
                    System.Console.WriteLine("WEDDING DATE VALID!");
                    System.Console.WriteLine("WEDDING DATE VALID!");
                    System.Console.WriteLine("WEDDING DATE VALID!");
                    WeddingPlanner.Models.Wedding newWedding = new WeddingPlanner.Models.Wedding {
                        WedderOne      = myWedding.WedderOne,
                        WedderTwo      = myWedding.WedderTwo,
                        Date           = myWedding.Date,
                        WeddingAddress = myWedding.WeddingAddress,
                        WedCreated_At  = DateTime.Now,
                        WedUpdated_At  = DateTime.Now,
                        Userid         = (int)HttpContext.Session.GetInt32("id")
                    };
                    _context.Add(newWedding);
                    _context.SaveChanges();
                    return(RedirectToAction("Dashboard", "Planner", new { id = (int)HttpContext.Session.GetInt32("id") }));
                }
                ViewBag.BadDate = ("Date cannot be from the past");
            }
            else
            {
                ViewBag.Errors = ModelState.Values;
            }
            return(View("MakingWedding"));
        }
 public void UpdateWedding(Wedding wedding)
 {
     Update(wedding);
     SaveChanges();
 }
Esempio n. 4
0
 public void Create(Wedding w)
 {
     Add(w);
     SaveChanges();
 }