Ejemplo n.º 1
0
        public async Task <IActionResult> PutOrder([FromRoute] int id, [FromBody] dynamic order)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != (int)order.numberOfOrder)
            {
                return(BadRequest());
            }

            var found = await _context.Order.SingleOrDefaultAsync(o => o.NumberOfOrder == id);

            var startStreetName = (string)order.startStreet;
            var startStreet     = await _context.Street.FirstOrDefaultAsync(s => s.Name == startStreetName);

            var endStreetName = (string)order.finalStreet;
            var endStreet     = await _context.Street.FirstOrDefaultAsync(s => s.Name == endStreetName);

            if (found == null)
            {
                return(NotFound());
            }

            found.StartStreet        = startStreet;
            found.NumberOfStartHouse = (string)order.numberOfStartHouse;
            found.FinalStreet        = endStreet;
            found.NumberOfFinalHouse = (string)order.numberOfFinalHouse;

            await _context.SaveChangesAsync();

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("ClientId,NumberOfTelephone,AmountOfOrders,AnountOfPoints")] Client client)
        {
            if (ModelState.IsValid)
            {
                _context.Add(client);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("NumberOfOrder,StartStreetId,NumberOfStartHouse,Time,FinalStreetId,NumberOfFinalHouse,TimeOfEndingOrder,NumberOfRecord,DispetcherId,ClientId,RealValue,AmountOfWrittenPoints,Value,AmountOfAccruedPoints")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClientId"]       = new SelectList(_context.Client, "ClientId", "ClientId", order.ClientId);
            ViewData["DispetcherId"]   = new SelectList(_context.Dispetcher, "DispetcherId", "DispetcherId", order.DispetcherId);
            ViewData["FinalStreetId"]  = new SelectList(_context.Street, "StreetId", "Name", order.FinalStreetId);
            ViewData["NumberOfRecord"] = new SelectList(_context.Record, "NumberOfRecord", "NumberOfRecord", order.NumberOfRecord);
            ViewData["StartStreetId"]  = new SelectList(_context.Street, "StreetId", "Name", order.StartStreetId);
            return(View(order));
        }