Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
            }
        }
Esempio n. 3
0
        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));
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
        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));
        }
Esempio n. 8
0
        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));
        }
Esempio n. 9
0
        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));
        }
Esempio n. 10
0
        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));
        }
Esempio n. 11
0
        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));
        }
Esempio n. 13
0
        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));
        }
Esempio n. 14
0
        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));
        }
Esempio n. 15
0
        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));
        }
Esempio n. 16
0
        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));
        }
Esempio n. 17
0
        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));
        }
Esempio n. 18
0
        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));
        }
Esempio n. 19
0
        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));
        }
Esempio n. 20
0
        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));
                }
            }
        }
Esempio n. 21
0
        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));
        }
Esempio n. 22
0
        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));
        }
Esempio n. 23
0
        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));
        }
Esempio n. 24
0
        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));
        }
Esempio n. 25
0
        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));
        }
Esempio n. 26
0
        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));
        }
Esempio n. 27
0
        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));
        }
Esempio n. 28
0
        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));
        }
Esempio n. 30
0
        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));
        }