示例#1
0
        public async Task <IActionResult> Create(String Author, String Title, DateTime ReleaseDate, String Genre, int Price, String Adress, String email, String password)
        {
            Book book = new Book(Author, Title, Adress, ReleaseDate, Genre, Price);

            if (ModelState.IsValid && _context.User.Any(user => user.Email == email && user.Password == password))
            {
                _context.Add(book);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
示例#2
0
        public void CreateCart(string username, string productName)
        {
            string       custId = GetCust(username).Id;
            string       prodId = GetProd(productName).Id;
            ShoppingCart cart   = new ShoppingCart();

            cart.Id         = Guid.NewGuid().ToString();
            cart.CustomerId = custId;
            cart.ProductId  = prodId;
            cart.ProductQty = 1;
            dbcontext.Add(cart);
            dbcontext.SaveChanges();
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Email,SubID")] Webappmaster webappmaster)
        {
            if (ModelState.IsValid && webappmaster.SubID != 0)
            {
                if (_context.Webappmaster.Count(e => e.Email == webappmaster.Email && e.SubID == webappmaster.SubID) == 0)
                {
                    if (IsValidEmail(webappmaster.Email))
                    {
                        _context.Add(webappmaster);
                        await _context.SaveChangesAsync();

                        return(RedirectToAction(nameof(Index)));
                    }
                    else
                    {
                        ModelState.AddModelError("Email", "Please enter a valid email address");
                    }
                }
                else
                {
                    ModelState.AddModelError("Email", "Email already subscribed to that magazine");
                }
            }
            else
            {
                ModelState.AddModelError("SubID", "Please select a magazine");
            }

            return(View(webappmaster));
        }
 public async Task<IActionResult> Create([Bind("ID,Title,ReleaseDate,Genre,Price")] Movie movie)
 {
     if (ModelState.IsValid)
     {
         _context.Add(movie);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     return View(movie);
 }
示例#5
0
 public IActionResult Registro(Registro r)
 {
     if (ModelState.IsValid)
     {
         _context.Add(r);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(r));
 }
示例#6
0
 public IActionResult Producto(Productos p)
 {
     if (ModelState.IsValid)
     {
         _context.Add(p);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(p));
 }
示例#7
0
 public IActionResult Formulario(Formulario f)
 {
     if (ModelState.IsValid)
     {
         _context.Add(f);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(f));
 }
示例#8
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Role role)
        {
            if (ModelState.IsValid)
            {
                _context.Add(role);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(role));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,RefreshTime")] Site site)
        {
            if (ModelState.IsValid)
            {
                _context.Add(site);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(site));
        }
示例#10
0
        public async Task <IActionResult> Create([Bind("Id,Name,Color")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
示例#11
0
        public async Task <IActionResult> Create([Bind("Id,Title,Url")] Bookmark bookmark)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bookmark);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bookmark));
        }
示例#12
0
        public async Task <IActionResult> Create([Bind("Id,Date,Latitude,Longitude,GeoPolygon,Photo,PhotoName,FileType,Geolocalization,GeoJSON,FireTypeClassification,SmokeTypeClassification,FireScoreClassification,SmokeScoreClassification")] ClassifiedImage classifiedImage)
        {
            if (ModelState.IsValid)
            {
                _context.Add(classifiedImage);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(classifiedImage));
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Order")] Process process)
        {
            if (ModelState.IsValid)
            {
                _context.Add(process);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Deals"));
            }
            return(View(process));
        }
示例#14
0
        public async Task <IActionResult> Create([Bind("PersonId,FirstName,LastName,PersonalCode,PersonPaymentMethod,PersonRequests,ParticipantId")] Person person)
        {
            if (ModelState.IsValid)
            {
                _context.Add(person);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(person));
        }
        public async Task <IActionResult> Create([Bind("CategoriaID,Nombre,Descripcion,Estado")] Categoria categoria)
        {
            if (ModelState.IsValid)
            {
                _context.Add(categoria);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoria));
        }
示例#16
0
        public async Task <IActionResult> Create([Bind("CompanyId,CompanyName,CompanyRegistrationNr,CompanyPaymentMehtod,NumberOfParticipants,CompanyRequests,ParticipantId")] Company company)
        {
            if (ModelState.IsValid)
            {
                _context.Add(company);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(company));
        }
示例#17
0
        public async Task <IActionResult> Create([Bind("Id,Brand,Model,Year,Hk,Price")] Car car)
        {
            if (ModelState.IsValid)
            {
                _context.Add(car);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(car));
        }
示例#18
0
        public async Task <IActionResult> Create([Bind("CategoryId,Name")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
示例#19
0
        public async Task <IActionResult> Create([Bind("Id,Nom,Email,Texte,DateCommentaire")] Commentaire commentaire)
        {
            if (ModelState.IsValid)
            {
                _context.Add(commentaire);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(commentaire));
        }
示例#20
0
        public async Task <IActionResult> Create([Bind("Id,Name,Phone,Address")] Company company)
        {
            if (ModelState.IsValid)
            {
                _context.Add(company);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(company));
        }
示例#21
0
        public async Task <IActionResult> Create([Bind("ReservationId,DateAndTime,LastName,PeopleNo")] Reservation reservation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(reservation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(reservation));
        }
示例#22
0
        public async Task <IActionResult> Create([Bind("Departamento,Id")] Department department)
        {
            if (ModelState.IsValid)
            {
                _context.Add(department);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
示例#23
0
        public async Task <IActionResult> Create([Bind("ID,EventName,EventStartDate,EventLocation,EventInformation")] Event @event)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@event);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(@event));
        }
示例#24
0
        public async Task <IActionResult> Create([Bind("TypeId,OrderType1")] OrderType orderType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orderType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(orderType));
        }
示例#25
0
        public async Task <IActionResult> Create([Bind("Id,Names,BirthDate,Gender,Worth")] People people)
        {
            if (ModelState.IsValid)
            {
                _context.Add(people);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(people));
        }
        public async Task <IActionResult> Create([Bind("Id,Name")] Group @group)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@group);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(@group));
        }
示例#27
0
        public async Task <IActionResult> Create([Bind("Id,FullName,Department, Email, Telephone")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
示例#28
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Address,City,State,DateOfBirth,Gender")] Student student)
        {
            if (ModelState.IsValid)
            {
                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Home"));
            }
            return(View(student));
        }
示例#29
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,Patronymic,LastName,Phone,Address,CompanyId")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contact);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Name", contact.CompanyId);
            return(View(contact));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Email,Phone,Message,ProductId")] Feedback feedback)
        {
            if (ModelState.IsValid)
            {
                _context.Add(feedback);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", feedback.ProductId);
            return(View(feedback));
        }