Ejemplo n.º 1
0
        public WeddingViewModel InitializeWeddingForm(WeddingViewModel WVM)
        {
            WVM.WeddingBO       = new WeddingBO();
            WVM.BrideAndMaidsBO = new BrideAndMaidBO();
            WVM.GroomAndMenBO   = new GroomAndManBO();
            WVM.TimeLineBO      = new TimeLineBO();
            WVM.WeddingEventsBO = new WeddingEventBO();

            if (WEDDINGID > 0)
            {
                HttpContext.Session[PageConstants.SESSION_WEDDING_ID] = WEDDINGID;
                WVM.WeddingBO = WeddingBusinessInstance.GetWeddingDetailByID(WEDDINGID);
                if (WVM.WeddingBO.BrideAndMaids != null && WVM.WeddingBO.BrideAndMaids.Count > 0)
                {
                    WVM.BrideAndMaidsBO = WVM.WeddingBO.BrideAndMaids.Where(x => x.IsBride).FirstOrDefault();
                }
                else
                {
                    WVM.BrideAndMaidsBO         = new BrideAndMaidBO();
                    WVM.BrideAndMaidsBO.IsBride = true;
                }
                if (WVM.WeddingBO.GroomAndMen != null && WVM.WeddingBO.GroomAndMen.Count > 0)
                {
                    WVM.GroomAndMenBO = WVM.WeddingBO.GroomAndMen.Where(x => x.IsGroom).FirstOrDefault();
                }
                else
                {
                    WVM.GroomAndMenBO         = new GroomAndManBO();
                    WVM.GroomAndMenBO.IsGroom = true;
                }
                WVM.TimeLineBO = new TimeLineBO();
            }

            return(WVM);
        }
Ejemplo n.º 2
0
        public IActionResult CreateWedding(WeddingViewModel model)
        {
            if (ModelState.IsValid)
            {
                Wedding newWedding = new Wedding
                {
                    Groom_Name   = model.Groom_Name,
                    Bride_Name   = model.Bride_Name,
                    Wedding_Date = model.Wedding_Date,
                    user_id      = (int)HttpContext.Session.GetInt32("CurrUserId"),
                    created_at   = DateTime.Now,
                    updated_at   = DateTime.Now
                };
                _context.Wedding.Add(newWedding);
                _context.SaveChanges();
                return(RedirectToAction("weddingPage"));
            }
            List <string> errors = ModelState.Select(x => x.Value.Errors)
                                   .Where(y => y.Count > 0)
                                   .Select(z => z[0].ErrorMessage.ToString())
                                   .ToList();

            TempData["error_list"] = errors;
            return(RedirectToAction("weddingPage"));
        }
Ejemplo n.º 3
0
 public IActionResult SaveWedding(WeddingViewModel newWedding)
 {
     if (ModelState.IsValid)
     {
         WeddingCreator NewWedding = new WeddingCreator
         {
             WeddingOne     = newWedding.WeddingOne,
             WeddingTwo     = newWedding.WeddingTwo,
             Date           = newWedding.Date,
             WeddingAddress = newWedding.WeddingAddress,
             Created_at     = DateTime.Now,
             Updated_at     = DateTime.Now,
             UserId         = (int)HttpContext.Session.GetInt32("UserId")
         };
         List <Guest> Guests = _context.Guests
                               .Include(user => user.User)
                               .Include(wedding => wedding.Wedding)
                               .ToList();
         _context.Weddings.Add(NewWedding);
         ViewBag.allweddings = new List <string>();
         _context.SaveChanges();
         return(RedirectToAction("AllWeddings"));
     }
     else
     {
         ViewBag.Errors = ModelState.Values;
         return(View("CreateWedding"));
     }
 }
Ejemplo n.º 4
0
 public ActionResult _WizardBrideMaids(WeddingViewModel WVM)
 {
     //WeddingViewModel WVM = new WeddingViewModel();
     WVM.BrideAndMaidsBO.CreatedBy      = UserID;
     WVM.BrideAndMaidsBO.BrideAndMaidID = WeddingBusinessInstance.SubmitBrideMaids(WEDDINGID, WVM.BrideAndMaidsBO);
     // Get wedding BrideMaids
     WVM.GroomAndMenBO   = WeddingBusinessInstance.GetWeddingDetailByID(WEDDINGID).GroomAndMen.Where(x => x.IsGroom).FirstOrDefault();
     WVM.BrideAndMaidsBO = WVM.WeddingBO.BrideAndMaids.Where(x => x.IsBride).FirstOrDefault();
     if (WVM.GroomAndMenBO == null)
     {
         WVM.GroomAndMenBO.WeddingID = WEDDINGID;
         WVM.GroomAndMenBO           = new GroomAndManBO();
     }
     if (WVM.GroomAndMenBO.GroomAndMenID > 0)
     {
         ViewBag.GroomMenForm = true;
         DropDown DD = new DropDown();
         ViewBag.RelationsList = DD.GetBrideGroomRelations();
         return(View("Index", WVM));
     }
     else
     {
         return(PartialView("_WizardBrideMaids", WVM));
     }
 }
Ejemplo n.º 5
0
        public ActionResult SubmitGroomsMen(WeddingViewModel model, FormCollection collection)
        {
            model.GroomAndMenBO.WeddingID = WEDDINGID;
            if (model.GroomAndMenBO.GroomAndMenID == 0)
            {
                model.GroomAndMenBO.IsActive    = true;
                model.GroomAndMenBO.IsDeleted   = false;
                model.GroomAndMenBO.CreatedBy   = UserID;
                model.GroomAndMenBO.CreatedDate = DateTime.Now;
            }

            model.GroomAndMenBO.GroomAndMenID = WeddingBusinessInstance.SubmitGroomMen(model.GroomAndMenBO.WeddingID, model.GroomAndMenBO);
            if (model.GroomAndMenBO.GroomAndMenID > 0)
            {
                ViewBag.IsSuccess = true;
                ViewBag.ShowPopup = true;
                ViewBag.Message   = "Groom's Man submitted successfully.";
            }
            else
            {
                ViewBag.IsSuccess = false;
                ViewBag.ShowPopup = true;
                ViewBag.Message   = "OOPs something went wrong. Try again!";
            }
            DropDown DD = new DropDown();

            ViewBag.RelationsList = DD.GetBrideGroomRelations();
            ViewBag.ShowPopUp     = true;
            return(RedirectToAction("Create", "Wedding", new { tid = TEMPLATEID, weddingID = WEDDINGID }));
        }
Ejemplo n.º 6
0
        public IActionResult AddWedding(WeddingViewModel model)
        {
            List <string> allErrors   = new List <string>();
            User          CurrentUser = _context.Users.SingleOrDefault(person => person.id == (int)HttpContext.Session.GetInt32("CurrUserId"));

            if (ModelState.IsValid)
            {
                Wedding newWedding = new Wedding
                {
                    Wedder1_Name    = model.Wedder1_Name,
                    Wedder2_Name    = model.Wedder2_Name,
                    Wedding_Date    = (DateTime)model.Wedding_Date,
                    Wedding_Address = model.Wedding_Address,
                    created_at      = DateTime.Now,
                    updated_at      = DateTime.Now,
                    user_id         = CurrentUser.id
                };
                _context.Add(newWedding);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            List <string> errors = ModelState.Select(x => x.Value.Errors)
                                   .Where(y => y.Count > 0)
                                   .Select(z => z[0].ErrorMessage.ToString())
                                   .ToList();

            foreach (var i in errors)
            {
                System.Console.WriteLine(i);
            }
            TempData["Errors"] = errors;
            return(RedirectToAction("NewWedding"));
        }
Ejemplo n.º 7
0
        public IActionResult CreateWedding(WeddingViewModel NewWedding)
        {
            int?id = HttpContext.Session.GetInt32("Id");

            if (ModelState.IsValid)
            {
                weddings Nwedding = new weddings()
                {
                    usersid    = (int)id,
                    wedder_1   = NewWedding.wedder_1,
                    wedder_2   = NewWedding.wedder_2,
                    date       = NewWedding.date,
                    location   = NewWedding.address,
                    created_at = DateTime.Now,
                    updated_at = DateTime.Now
                };
                if (NewWedding.date < DateTime.Today)
                {
                    ModelState.AddModelError("date", "Marry in the past? are you sure?");
                    return(View("createwedding"));
                }
                _context.Add(Nwedding);
                _context.SaveChanges();
                return(RedirectToAction("Wedding"));
            }
            return(View("createwedding"));
        }
Ejemplo n.º 8
0
        public ActionResult Create(int?tID, int?weddingID)
        {
            TEMPLATEID = (int)tID == 0 ? TEMPLATEID : (int)tID;
            WEDDINGID  = weddingID == null ? WEDDINGID : (int)weddingID;
            WeddingViewModel WVM = new WeddingViewModel();

            UserWeddingTemplateSubscriptionsBO weddingProfile = HttpContext.Session[PageConstants.SESSION_WEDDING_PROFILE] as UserWeddingTemplateSubscriptionsBO;

            if (weddingID > 0)
            {
                InitializeWeddingForm(WVM);
            }
            else
            {
                WVM.WeddingBO       = new WeddingBO();
                WVM.BrideAndMaidsBO = new BrideAndMaidBO();
                WVM.GroomAndMenBO   = new GroomAndManBO();
                WVM.TimeLineBO      = new TimeLineBO();
                WVM.WeddingEventsBO = new WeddingEventBO();
            }
            DropDown DD = new DropDown();

            ViewBag.RelationsList    = DD.GetBrideGroomRelations();
            WVM.listTemplates        = weddingProfile.Templates.ToList();
            WVM.userTemplate         = WVM.listTemplates.Where(x => x.TemplateID == TEMPLATEID).FirstOrDefault();
            WVM.WeddingBO.TemplateID = TEMPLATEID;

            WVM.WeddingBO.TemplateImageUrl   = WVM.userTemplate.ThumbnailImageUrl;
            WVM.WeddingBO.TemplatePreviewUrl = WVM.userTemplate.TemplatePreviewUrl;
            return(View(WVM));
        }
Ejemplo n.º 9
0
        public PartialViewResult _WizardWedding(WeddingViewModel wedding)
        {
            WeddingViewModel WVM = new WeddingViewModel();

            WVM.WeddingBO           = wedding.WeddingBO;
            WVM.WeddingBO.WeddingID = WeddingBusinessInstance.SubmitUserWeddingDetail(UserID, wedding.WeddingBO);
            WEDDINGID = WVM.WeddingBO.WeddingID;
            // Get wedding BrideMaids
            WVM.WeddingBO.BrideAndMaids = WeddingBusinessInstance.GetWeddingBrideMaids(wedding.WeddingBO.WeddingID);
            WVM.BrideAndMaidsBO         = WVM.WeddingBO.BrideAndMaids.Where(x => x.IsBride).FirstOrDefault();
            if (WVM.BrideAndMaidsBO == null)
            {
                WVM.BrideAndMaidsBO           = new BrideAndMaidBO();
                WVM.BrideAndMaidsBO.WeddingID = WEDDINGID;
            }
            if (WEDDINGID > 0)
            {
                ViewBag.BrideMaidForm = true;
                DropDown DD = new DropDown();
                ViewBag.RelationsList = DD.GetBrideGroomRelations();
                return(PartialView("_WizardWedding", WVM));
            }
            else
            {
                return(PartialView("_WizardWedding", WVM));
            }
        }
Ejemplo n.º 10
0
 public IActionResult CreateWedding(WeddingViewModel AddNewWedding, int UserId)
 {
     System.Console.WriteLine("##################################################");
     System.Console.WriteLine(AddNewWedding.WedderOne);
     System.Console.WriteLine(AddNewWedding.WedderOne);
     System.Console.WriteLine(AddNewWedding.Date);
     System.Console.WriteLine(AddNewWedding.Address);
     System.Console.WriteLine("##################################################");
     System.Console.WriteLine("\n\n\t=== + IN create wedding action    ==== \n\n");
     if (ModelState.IsValid)
     {
         // System.Console.WriteLine("\n\n\t=== + IN WEDDING CREATE NEW    ==== \n\n");
         Wedding thiswedding = new Wedding
         {
             WedderOne = AddNewWedding.WedderOne,
             WedderTwo = AddNewWedding.WedderTwo,
             Date      = AddNewWedding.Date,
             Address   = AddNewWedding.Address,
             User      = _context.Users.SingleOrDefault(user => user.UserId == UserId)
         };
         System.Console.WriteLine("\n\n\t=== + IN WEDDING CREATE NEW    ==== \n\n");
         _context.Add(thiswedding);
         _context.SaveChanges();
         return(RedirectToAction("Dashboard"));
     }
     else
     {
         System.Console.WriteLine("\n\n\t=== + IN WEDDING ERRORS  ELSE    ==== \n\n");
         return(View("AddNew"));
     }
 }
Ejemplo n.º 11
0
        public ActionResult SubmitBrideMaids(WeddingViewModel model)
        {
            DropDown DD = new DropDown();

            ViewBag.RelationsList = DD.GetBrideGroomRelations();

            if (model.BrideAndMaidsBO.BrideAndMaidID == 0)
            {
                model.BrideAndMaidsBO.IsActive    = true;
                model.BrideAndMaidsBO.IsDeleted   = false;
                model.BrideAndMaidsBO.CreatedBy   = UserID;
                model.BrideAndMaidsBO.CreatedDate = DateTime.Now;
            }

            model.BrideAndMaidsBO.WeddingID      = WEDDINGID;
            model.BrideAndMaidsBO.BrideAndMaidID = WeddingBusinessInstance.SubmitBrideMaids(model.BrideAndMaidsBO.WeddingID, model.BrideAndMaidsBO);

            if (model.BrideAndMaidsBO.BrideAndMaidID > 0)
            {
                //RenameNewImageFile(model.BrideAndMaidsBO.Imageurl, model.BrideAndMaidsBO.BrideAndMaidID);
                ViewBag.IsSuccess = true;
                ViewBag.ShowPopup = true;
                ViewBag.Message   = "Bride Maid's detail submitted successfully.";
            }
            else
            {
                ViewBag.ShowPopup = true;
                ViewBag.IsSuccess = false;
                ViewBag.Message   = "OOPs something went wrong. Try again!";
            }
            ViewBag.ShowPopUp = true;
            return(RedirectToAction("Create", "Wedding", new { tid = TEMPLATEID, weddingID = WEDDINGID }));
        }
        public IActionResult ViewWedding(int id)
        {
            WeddingViewModel ViewWedding = new WeddingViewModel()
            {
                ThisWedding = dbContext.Weddings
                              .Include(wed => wed.Guests)
                              .ThenInclude(g => g.Guest)
                              .FirstOrDefault(w => w.WeddingId == id)
            };
            string UserFirstName = HttpContext.Session.GetString("FirstName");

            ViewBag.FirstName = UserFirstName;
            return(View("ViewWedding", ViewWedding));
        }
Ejemplo n.º 13
0
        public JsonResult GetTimeLineDetailsByID(int Id)
        {
            WeddingViewModel WVM = new WeddingViewModel();

            try
            {
                WVM.TimeLineBO = WeddingBusinessInstance.GetTimeLineDetailsByID(Id);
                return(Json(WVM, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 14
0
        public IActionResult NewWedding(WeddingViewModel model)
        {
            // Check to ensure form data is legal.
            if (ModelState.IsValid)
            {
                // Check to ensure wedding date is in the future.
                if (model.DateOfWedding > DateTime.Now)
                {
                    // Insert wedding data into db.
                    try
                    {
                        // Set sessionId to be AdminId in db.
                        int?    AdminId    = HttpContext.Session.GetInt32("LoggedUserId");
                        Wedding NewWedding = new Wedding
                        {
                            AdminId       = (int)AdminId,
                            WifeName      = model.WifeName,
                            HusbandName   = model.HusbandName,
                            Address       = model.Address,
                            DateOfWedding = model.DateOfWedding,
                            CreatedAt     = DateTime.Now,
                        };
                        // Add new wedding to DB.
                        _context.Weddings.Add(NewWedding);
                        // Get the WeddingId in order to redirect to the proper page.
                        var CurrentWedding = _context.Weddings.Where(w => w.AdminId == AdminId).LastOrDefault();
                        _context.SaveChanges();

                        // After successful creation of new wedding redirect to that wedding's specific page.
                        return(RedirectToAction("WeddingDetails", new { WeddingId = CurrentWedding.WeddingId }));
                    }
                    // Catch should only run if insertion of data into DB failed.
                    catch
                    {
                        ViewBag.WeddingErrors = "Oh No! There was an error saving your new wedding. Please try again.";
                        return(View("PlanWedding"));
                    }
                }
                else
                {
                    ViewBag.WeddingErrors = "We know you want to get married soon but the date of the Wedding must be in the future, not the past.";
                    return(View("PlanWedding"));
                }
            }
            else
            {
                return(View("PlanWedding"));
            }
        }
Ejemplo n.º 15
0
        public IActionResult Wedding(int WeddingId)
        {
            if (HttpContext.Session.GetString("userInSess") != null)
            {
                WeddingViewModel viewModel = new WeddingViewModel();

                Wedding thisWedding = dbContext.Weddings
                                      .Include(uw => uw.UserWeddings)
                                      .ThenInclude(ug => ug.User)
                                      .FirstOrDefault(p => p.WeddingId == WeddingId);

                return(View("Wedding", thisWedding));
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 16
0
        // [Route("{wedding}/{Id:int}")]
        public ActionResult Index(int?Id)
        {
            WeddingViewModel WVM = new WeddingViewModel();

            //WeddingBO wedding = new WeddingBO();
            //UserWeddingTemplateSubscriptionsBO weddingProfile = HttpContext.Session[PageConstants.SESSION_WEDDING_PROFILE] as UserWeddingTemplateSubscriptionsBO;
            //WVM.listTemplates = weddingProfile.userTemplates.ToList();
            if (Id != null)
            {
                WVM.WeddingBO = WeddingBusinessInstance.GetWeddingDetailByID(Convert.ToInt32(Id));
            }
            ViewBag.WeddingForm = true;

            return(View(WVM));
        }
Ejemplo n.º 17
0
 public ActionResult Create(WeddingViewModel WVM)
 {
     WEDDINGID = WeddingBusinessInstance.SubmitUserWeddingDetail(UserID, WVM.WeddingBO);
     if (WEDDINGID > 0)
     {
         ViewBag.IsSuccess = true;
         ViewBag.Message   = "Congratulations! Your wedding basic details has been created.";
     }
     else
     {
         ViewBag.IsSuccess = false;
         ViewBag.Message   = "OOPs something went wrong. Try again!";
     }
     ViewBag.ShowPopUp = true;
     WVM = InitializeWeddingForm(WVM);
     return(View(WVM));
 }
        public IActionResult Dashboard()
        {
            if (HttpContext.Session.GetInt32("user_id") != null)
            {
                List <Wedding> AllWeddings = dbContext.Weddings
                                             .Include(wedding => wedding.Guests)
                                             .ToList();

                WeddingViewModel model = new WeddingViewModel()
                {
                    Weddings = AllWeddings,
                    User     = dbContext.Users.FirstOrDefault(u => u.UserId == SessionUser)
                };
                return(View(model));
            }
            return(RedirectToAction("Login", "Login"));
        }
Ejemplo n.º 19
0
        public JsonResult GetGroomDetailsByID(int Id)
        {
            WeddingViewModel WVM = new WeddingViewModel();

            try
            {
                DropDown DD = new DropDown();
                ViewBag.RelationsList = DD.GetBrideGroomRelations();
                WVM.GroomAndMenBO     = WeddingBusinessInstance.GetGroomDetailsByID(Id);
                return(Json(WVM, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            // return View();
        }
Ejemplo n.º 20
0
 public IActionResult addWedding(WeddingViewModel wedding)
 {
     if (ModelState.IsValid)
     {
         Wedding newWed = new Wedding {
             wedderOne  = wedding.wedderOne,
             wedderTwo  = wedding.wedderTwo,
             date       = wedding.date,
             wedAddress = wedding.wedAddress,
             createdBy  = (int)HttpContext.Session.GetInt32("id"),
         };
         _context.weddings.Add(newWed);
         _context.SaveChanges();
         return(RedirectToAction("dash", "User"));
     }
     return(View("newWedding"));
 }
Ejemplo n.º 21
0
        public IActionResult UpdateWedding(WeddingViewModel model)
        {
            Wedding UpdatingWedding = _context.Weddings.Where(w => w.WeddingId == model.WeddingId).FirstOrDefault();

            if (UpdatingWedding != null)
            {
                UpdatingWedding.SpouseOne = model.SpouseOne;
                UpdatingWedding.SpouseTwo = model.SpouseTwo;
                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));
        }
Ejemplo n.º 22
0
        public IActionResult CreateWedding(WeddingViewModel WeddingInfo)
        {
            if (ModelState.IsValid)
            {
                Wedding NewWedding = new Wedding
                {
                    NameOne   = WeddingInfo.NameOne,
                    NameTwo   = WeddingInfo.NameTwo,
                    Date      = WeddingInfo.Date,
                    Address   = WeddingInfo.Address,
                    CreatorId = (int)HttpContext.Session.GetInt32("CurId"),
                };
                _context.Add(NewWedding);

                _context.SaveChanges();
                return(RedirectToAction("Dashboard"));
            }
            return(View("AddWedding", WeddingInfo));
        }
Ejemplo n.º 23
0
 public IActionResult AddWeddingToDb(WeddingViewModel model)
 {
     if (ModelState.IsValid)
     {
         Wedding newWedding = new Wedding
         {
             WedderOne  = model.WedderOne,
             WedderTwo  = model.WedderTwo,
             WeddDate   = model.WeddDate,
             WedAddress = model.WedAddress,
             CreatorId  = HttpContext.Session.GetInt32("userId").Value
         };
         _context.weddings.Add(newWedding);
         _context.SaveChanges();
         var weId = newWedding.WeddingId;
         return(RedirectToAction("ShowWedding", new { WedId = weId }));
     }
     return(View("WedAdder"));
 }
Ejemplo n.º 24
0
        public ActionResult SubmitEvent(int?Id)
        {
            WeddingViewModel WVM = new WeddingViewModel();
            UserWeddingTemplateSubscriptionsBO weddingProfile = new UserWeddingTemplateSubscriptionsBO();

            WVM.listTemplates = weddingProfile.Templates.ToList();
            WVM.userTemplate  = WVM.listTemplates.Where(x => x.TemplateID == TEMPLATEID).FirstOrDefault();

            try
            {
                WVM.WeddingBO = WeddingBusinessInstance.GetWeddingDetailByID(WEDDINGID);
                if (WVM.WeddingBO.WeddingEvents.Count > 0 && Id > 0)
                {
                    WVM.WeddingEventsBO = WVM.WeddingBO.WeddingEvents.Where(x => x.WeddingEventID == Id).FirstOrDefault();
                    WeddingEventBO myEvent = new WeddingEventBO();
                    WVM.WeddingEventsBO.Venue = new VenueBO();
                    WVM.WeddingEventsBO.Venue.WeddingEventID = WVM.WeddingEventsBO.WeddingEventID;
                    myEvent = WVM.WeddingEventsBO;

                    // myEvent.strStartTime = WVM.WeddingEventsBO.StartTime.ToShortTimeString();
                    // myEvent.strEndTime = WVM.WeddingEventsBO.EndTime.ToShortTimeString();
                    if (myEvent.Venues.Count() > 0)
                    {
                        WVM.WeddingEventsBO.Venue = myEvent.Venues.FirstOrDefault();
                        WVM.WeddingEventsBO.Venue.VenueAddress = SystemBusinessInstance.GetAddressDetails(0, myEvent.Venue.VenueID, (int)AspectEnums.AddressOwnerType.Venue);
                    }
                    return(View(WVM));
                }
                else
                {
                    WVM.WeddingEventsBO       = new WeddingEventBO();
                    WVM.WeddingEventsBO.Venue = new VenueBO();
                    WVM.WeddingEventsBO.Venue.VenueAddress = new AddressMasterBO();
                    return(View(WVM));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            // return View();
        }
Ejemplo n.º 25
0
        public ActionResult SubmitTimeLine(WeddingViewModel model)
        {
            model.TimeLineBO.WeddingID  = WEDDINGID;
            model.TimeLineBO.TimeLineID = WeddingBusinessInstance.SubmitTimeLine(WEDDINGID, model.TimeLineBO);

            if (model.TimeLineBO.TimeLineID > 0)
            {
                ViewBag.IsSuccess = true;
                ViewBag.Message   = "TimeLine submitted successfully.";
            }
            else
            {
                ViewBag.IsSuccess = false;
                ViewBag.Message   = "OOPs something went wrong. Try again!";
            }
            ViewBag.ShowPopUp = true;
            //return Json(model, JsonRequestBehavior.AllowGet);
            return(RedirectToAction("Create", "Wedding", new { tid = TEMPLATEID, weddingID = WEDDINGID }));
            //return PartialView("_SubmitTimeLine", model);
        }
Ejemplo n.º 26
0
 public IActionResult createWedding(WeddingViewModel model)
 {
     if (ModelState.IsValid)
     {
         Wedding newWedding = new Wedding
         {
             CreatedBy = ActiveUser.UserId,
             Wedder1   = model.Wedder1,
             Wedder2   = model.Wedder2,
             Date      = model.Date,
             Address   = model.Address,
         };
         _context.Wedding.Add(newWedding);
         _context.SaveChanges();
         Wedding wedding = _context.Wedding.Where(w => w.Wedder1 == model.Wedder1 && w.Wedder2 == model.Wedder2).SingleOrDefault();
         return(RedirectToAction("ShowWedding", new { WeddingId = wedding.WeddingId }));
     }
     ViewBag.UserInfo = ActiveUser;
     return(View("NewWedding"));
 }
        public IActionResult CreateWedding(WeddingViewModel model)
        {
            int myId = (int)HttpContext.Session.GetInt32("userId");

            if (ModelState.IsValid)
            {
                Wedding NewWedding = new Wedding
                {
                    wedder1 = model.wedder1,
                    wedder2 = model.wedder2,
                    date    = model.date,
                    address = model.address,
                    userId  = myId
                };
                _context.Add(NewWedding);
                _context.SaveChanges();
                return(RedirectToAction("LoadDash"));
            }
            @ViewBag.errors = ModelState.Values;
            return(View("Form"));
        }
Ejemplo n.º 28
0
 public IActionResult AddWedding(WeddingViewModel model)
 {
     if (ModelState.IsValid)
     {
         if (model.Date < DateTime.Today)
         {
             ModelState.AddModelError("date", "Date cannot be set to future date!");
             return(View("Wedding", model));
         }
         Wedding NewWedding = new Wedding {
             SpouseOne = model.SpouseOne,
             SpouseTwo = model.SpouseTwo,
             Date      = model.Date,
             Address   = model.Address
         };
         _context.Add(NewWedding);
         _context.SaveChanges();
         return(RedirectToAction("Wedding", new { Id = NewWedding.WeddingId }));
     }
     return(View("Wedding", model));
 }
Ejemplo n.º 29
0
        public IActionResult Create(WeddingViewModel model)
        {
            List <string> allErrors   = new List <string>();
            User          CurrentUser = _context.Users.SingleOrDefault(person => person.UserId == (int)HttpContext.Session.GetInt32("CurrentUserId"));

            System.Console.WriteLine("In Register***********************************************");
            System.Console.WriteLine(model);
            if (ModelState.IsValid)
            {
                Wedding newWedding = new Wedding {
                    WedderOne = model.WedderOne,
                    WedderTwo = model.WedderTwo,
                    Date      = model.Date,
                    Address   = model.Address,
                    CreatedAt = DateTime.Now,
                    UpdatedAt = DateTime.Now,
                    UserId    = CurrentUser.UserId,
                };

                System.Console.WriteLine(newWedding);
                _context.Add(newWedding);
                _context.SaveChanges();
                // HttpContext.Session.SetInt32("CurrentUserId", newWedding.UserId); This is how to set Http Session currid to newwedding.userid...dont need this here
                return(RedirectToAction("showpage", new { id = newWedding.WeddingId }));
            }
            System.Console.WriteLine("Not Good***********************************************");
            ViewBag.Errors = ModelState.Values;
            {
                foreach (var error in ViewBag.Errors)
                {
                    if (error.Errors.Count > 0)
                    {
                        System.Console.WriteLine(error.Errors[0].ErrorMessage);
                    }
                }
            }
            System.Console.WriteLine("Hello____________________*********");

            return(View("planpage"));
        }
Ejemplo n.º 30
0
 public IActionResult addWedding(WeddingViewModel model)
 {
     if (ModelState.IsValid)
     {
         if (model.Date < DateTime.Today)
         {
             ModelState.AddModelError("date", "Date Cannot be set to future date!");
             return(View("Wedding", model));
         }
         Wedding NewWedding = new Wedding {
             Bride   = model.Bride,
             Groom   = model.Groom,
             Date    = model.Date,
             UserId  = (int)HttpContext.Session.GetInt32("CurrUser"),
             Address = model.Address
         };
         _context.Add(NewWedding);
         _context.SaveChanges();
         return(RedirectToAction("Wedding", new { Id = NewWedding.WeddingId }));
     }
     return(View("WeddingForm"));
 }