Example #1
0
        public async Task <IActionResult> Create([Bind("CustomerId,CustFirstName,CustLastName,CustAddress,CustCity,CustProv,CustPostal,CustCountry,CustHomePhone,CustBusPhone,CustEmail,AgentId,PasswordNotHashed,PasswordHashed,PasswordSalt")] Customers customers)
        {
            var customer = from b in _context.Customers
                           where b.CustEmail.Equals(customers.CustEmail)
                           select b;

            if (customer.Count() > 0)
            {
                return(View("~/Views/Home/Index.cshtml"));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    _context.Add(customers);
                    Debug.WriteLine(_context.Customers);
                    await _context.SaveChangesAsync();

                    HttpContext.Session.SetString("userEmail", customers.CustEmail);
                    return(Redirect("~/"));
                }
            }

            return(View(customers));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("AgencyId,AgncyAddress,AgncyCity,AgncyProv,AgncyPostal,AgncyCountry,AgncyPhone,AgncyFax")] Agencies agencies)
        {
            if (ModelState.IsValid)
            {
                _context.Add(agencies);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(agencies));
        }
        public async Task <IActionResult> Create([Bind("PackageId,PkgName,PkgStartDate,PkgEndDate,PkgDesc,PkgBasePrice,PkgAgencyCommission")] Packages packages)
        {
            if (ModelState.IsValid)
            {
                _context.Add(packages);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(packages));
        }
Example #4
0
        public async Task <IActionResult> Create([Bind("AgentId,AgtFirstName,AgtMiddleInitial,AgtLastName,AgtBusPhone,AgtEmail,AgtPosition,AgencyId")] Agents agents)
        {
            if (ModelState.IsValid)
            {
                _context.Add(agents);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(agents));
        }
        public async Task <IActionResult> Create([Bind("CustomerId,CustFirstName,CustLastName,CustAddress,CustCity,CustProv,CustPostal,CustCountry,CustHomePhone,CustBusPhone,CustEmail,Username,Password,ConfirmPassword,AgentId")] Customers customers)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customers);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Bookings"));
            }
            //ViewData["AgentId"] = new SelectList(_context.Agents, "AgentId", "AgentId", customers.AgentId);
            return(View(customers));
        }
        public async Task <IActionResult> Create([Bind("BookingId,BookingDate,BookingNo,TravelerCount,CustomerId,TripTypeId,PackageId")] Bookings bookings)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bookings);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "CustAddress", bookings.CustomerId);
            ViewData["PackageId"]  = new SelectList(_context.Packages, "PackageId", "PkgName", bookings.PackageId);
            ViewData["TripTypeId"] = new SelectList(_context.TripTypes, "TripTypeId", "TripTypeId", bookings.TripTypeId);
            return(View(bookings));
        }
Example #7
0
 // Adds given class to db
 public void Add <T>(T entity) where T : class
 {
     context.Add(entity);
 }