public async Task <IActionResult> Create([Bind("Id,Name,Address,Age,PhoneNumber,MailAdress,Password,Type")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                //check if username already exists in database
                var isCustomerExist = CheckIfCustomerExist(customer);
                if (!isCustomerExist)
                {
                    _context.Add(customer);
                    await _context.SaveChangesAsync();

                    HttpContext.Session.SetString(CustomerKey, customer.Name);
                    HttpContext.Session.SetString(CustomerIdKey, customer.Id);
                }
                else
                {
                    // TODO - stay in the current view, and show an appropriate message
                    return(View("Create", customer));
                }
                //return RedirectToAction(nameof(Index));
                return(Redirect("~/Home/index"));
                //return RedirectToAction("Create", "SignUpApplications");
            }
            return(View(customer));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Date,Content,Opinion,Mark")] Comments comments)
        {
            if (ModelState.IsValid)
            {
                _context.Add(comments);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(comments));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("Id,LocationName")] Locations locations)
        {
            if (ModelState.IsValid)
            {
                _context.Add(locations);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(locations));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create([Bind("Id,NumOfTickets,TotalCost,Time")] Orders orders)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orders);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(orders));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Kind,State,Address,Age,Date,DurationTime")] Atractions atractions)
        {
            if (ModelState.IsValid)
            {
                _context.Add(atractions);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(atractions));
        }
        public async Task <IActionResult> Create([Bind("Id,CheckIn,CheckOut")] SignUpApplication signUpApplication)
        {
            if (ModelState.IsValid)
            {
                _context.Add(signUpApplication);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(signUpApplication));
        }
Esempio n. 7
0
        public async Task <Estudiante> DeleteEstudiante(int id)
        {
            var estudiante = await _context.Estudiantes.FindAsync(id);

            if (estudiante != null)
            {
                _context.Estudiantes.Remove(estudiante);
                await _context.SaveChangesAsync();

                return(estudiante);
            }
            return(estudiante);
        }
        public async Task <IActionResult> Create([Bind("CustomerId,AtractionId")] CustomerAtraction customerAtraction)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customerAtraction);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AtractionId"] = new SelectList(_context.Atractions, "Id", "Id", customerAtraction.AtractionId);
            ViewData["CustomerId"]  = new SelectList(_context.Customer, "Id", "Id", customerAtraction.CustomerId);
            return(View(customerAtraction));
        }