public async Task <IActionResult> Create([Bind("Id,FirstName,MiddleName,LastName,Address,Phone,Email,Stage,AccountId")] Client client) { if (ModelState.IsValid) { _context.Add(client); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(client)); }
public async Task <IActionResult> Create(User user) { try { var user1 = await _context.User.AsNoTracking().FirstOrDefaultAsync(m => m.Login == user.Login); if (user1 == null) { user.Password = HashPassword(user.Password); user.IsDeleted = 0; _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } else { ModelState.AddModelError("", "Login is taken"); return(View(user)); } } catch (Exception) { ModelState.AddModelError("", "Login is taken"); return(View(user)); } }
public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,PhoneNumber,EmailAddress")] CSOEmployee cSOEmployee) { if (ModelState.IsValid) { _context.Add(cSOEmployee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cSOEmployee)); }
public async Task <IActionResult> Create([Bind("Id,Description,DateTime,ComType")] Communication communication) { if (ModelState.IsValid) { _context.Add(communication); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(communication)); }
public async Task <IActionResult> Create([Bind("ID,Name,SetupDate,CostCenterCode")] Client client) { if (ModelState.IsValid) { _context.Add(client); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(client)); }
public async Task <IActionResult> Create([Bind("Id,Summary,Description,status,OpenDateTime,CloseDateTime")] Conversation conversation) { if (ModelState.IsValid) { _context.Add(conversation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(conversation)); }
public async Task <IActionResult> Create([Bind("ID,Price")] Product product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Create([Bind("Id,Article,Name,Price")] PartType partType) { if (ModelState.IsValid) { _context.Add(partType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(partType)); }
public async Task <IActionResult> Create([Bind("Id,OrderDate,Discount")] Order order) { if (ModelState.IsValid) { _context.Add(order); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(order)); }
public async Task <IActionResult> Create([Bind("Id")] InternalEmployee internalEmployee) { if (ModelState.IsValid) { _context.Add(internalEmployee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(internalEmployee)); }
public async Task <IActionResult> Create([Bind("ID,Username,Password,Tipo")] Usuario usuario) { if (ModelState.IsValid) { _context.Add(usuario); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(usuario)); }
public async Task <IActionResult> Create([Bind("Id,Name,Red,Green,Blue")] CarColor carColor) { if (ModelState.IsValid) { _context.Add(carColor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(carColor)); }
public async Task <IActionResult> Create([Bind("ServiceProductId,Summary,DurationDays,ID,Price")] ServiceProduct serviceProduct) { if (ModelState.IsValid) { _context.Add(serviceProduct); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(serviceProduct)); }
public async Task <IActionResult> Create([Bind("Id,WarrantyExpiry,discount")] OrderItem orderItem) { if (ModelState.IsValid) { _context.Add(orderItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(orderItem)); }
public async Task <IActionResult> Create([Bind("Id,Name,Requisites")] Partner partner) { if (ModelState.IsValid) { _context.Add(partner); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(partner)); }
public async Task <IActionResult> Create([Bind("TangibleProductId,Manufacture,Model,EndOfLife,ID,Price")] TangibleProduct tangibleProduct) { if (ModelState.IsValid) { _context.Add(tangibleProduct); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tangibleProduct)); }
public async Task <IActionResult> Create([Bind("Id,Name")] Vendor vendor) { if (ModelState.IsValid) { _context.Add(vendor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(vendor)); }
public async Task <IActionResult> Create([Bind("Id,StartDate,EndDate,WarrantyExpiry,discount")] ClientService clientService) { if (ModelState.IsValid) { _context.Add(clientService); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(clientService)); }
public async Task <IActionResult> Create([Bind("ID,BuildingName,PropertyNumber,AddressLine1,AddressLine2,AddressLine3,PostCode")] Address address) { if (ModelState.IsValid) { _context.Add(address); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(address)); }
public async Task <IActionResult> Register(User user) { try { var user1 = await _context.User.FirstOrDefaultAsync(m => m.Login == user.Login); if (user1.Id == 0) { if (ModelState.IsValid) { user.Password = HashPassword(user.Password); _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction("Login")); } return(View(user)); } else { ModelState.AddModelError("", "Login is taken"); return(View(user)); } } catch (Exception) { try { user.Password = HashPassword(user.Password); _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction("Login")); } catch (Exception) { ModelState.AddModelError("", "Invalid data"); return(View(user)); } } }
public async Task <IActionResult> Create([Bind("Id,Amount,OrderId")] Bill bill) { if (ModelState.IsValid) { bill.Date = DateTime.Now; _context.Add(bill); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bill)); }
public async Task <IActionResult> Create([Bind("Id,Name,EngineCapacity,EngineType,DriveUnitType,TransmissionType,VendorId")] CarModel carModel) { if (ModelState.IsValid) { _context.Add(carModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } PopulateVendorsDropDownList(carModel.VendorId); return(View(carModel)); }
public async Task <IActionResult> Create(Note note) { if (ModelState.IsValid) { note.IsDeleted = 0; _context.Add(note); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(note)); }
public async Task <IActionResult> Create([Bind("ID,Nombre,Cedula,Pagina_Web,Direccion,Telefono,Sector,IDUsuario")] Cliente cliente) { if (ModelState.IsValid) { cliente.IDUsuario = Convert.ToInt32(HttpContext.Session.GetInt32("userid")); _context.Add(cliente); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cliente)); }
public async Task <IActionResult> Create([Bind("ID,Titulo,Detalle,Quien_reporto,Estado_Actual,IDCliente,IDUsuario")] Ticket ticket) { if (ModelState.IsValid) { ticket.IDUsuario = Convert.ToInt32(HttpContext.Session.GetInt32("userid")); _context.Add(ticket); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IDCliente"] = new SelectList(_context.Cliente, "IDCliente", "Nombre", ticket.IDCliente); return(View(ticket)); }
public async Task <IActionResult> Create([Bind("ID,Titulo,DiaHora,Virtual,IDCliente,IDUsuario")] Reunion reunion) { if (ModelState.IsValid) { reunion.IDUsuario = Convert.ToInt32(HttpContext.Session.GetInt32("userid")); _context.Add(reunion); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IDCliente"] = new SelectList(_context.Cliente, "IDCliente", "Nombre", reunion.IDCliente); return(View(reunion)); }
public async Task <IActionResult> CreateCar([Bind("Id,VIN,Year,Price,ColorId,TestDrive,CarModelId,PartnerId")] Car car) { if (ModelState.IsValid) { _context.Add(car); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CarModelId"] = new SelectList(_context.CarModels.Include(c => c.Vendor).AsNoTracking(), "Id", null); ViewData["ColorId"] = new SelectList(_context.CarColors, "Id", "Name", car.ColorId); ViewData["PartnerId"] = new SelectList(_context.Partners, "Id", "Name", car.PartnerId); return(View(car)); }
public async Task <IActionResult> Create([Bind("ID,Nombre,Apellidos,Correo,Telefono,Puesto,IDCliente,IDUsuario")] Contacto contacto) { if (ModelState.IsValid) { contacto.IDUsuario = Convert.ToInt32(HttpContext.Session.GetInt32("userid")); _context.Add(contacto); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IDCliente"] = new SelectList(_context.Cliente, "IDCliente", "Nombre", contacto.IDCliente); return(View(contacto)); }
public async Task <IActionResult> Create([Bind("Id,DateTime,ClientId,CarId")] TestDrive testDrive) { if (ModelState.IsValid) { _context.Add(testDrive); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } var cars = await _context.Cars .Where(x => x.TestDrive) .Include(x => x.CarModel).ThenInclude(x => x.Vendor) .Include(x => x.Color).AsNoTracking().ToListAsync(); var clients = await _context.Clients.AsNoTracking().ToListAsync(); ViewData["Cars"] = cars; ViewData["Clients"] = clients; return(View(testDrive)); }
public async Task <IActionResult> Create(Company company) { //return View(model.Company); if (ModelState.IsValid) { try { company.IsDeleted = 0; _context.Add(company); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (DbUpdateException) { List <Business> businessesList = _context.Business.ToList(); ViewBag.data = businessesList; var user = await _context.User.FirstOrDefaultAsync(m => m.Login == User.FindFirst("user").Value); ViewBag.message = user.Id; ModelState.AddModelError("", "NIP Is Taken"); return(View(company)); } } return(View(company)); }