Пример #1
0
 public async Task <IActionResult> PostEditAccelerationModeApi(int id, [FromBody] AccelerationMode AccelerationMode)
 {
     if (ModelState.IsValid)
     {
         try
         {
             AccelerationMode.AccelerationModeId = id;
             _context.Update(AccelerationMode);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!AccelerationModeExists(AccelerationMode.AccelerationModeId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(Json("Success"));
     }
     return(Json("Fail"));
 }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("AccelerationModeId,Capacity,Type,Price,Weight,RunningCost,Range")] AccelerationMode accelerationMode)
        {
            if (id != accelerationMode.AccelerationModeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accelerationMode);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccelerationModeExists(accelerationMode.AccelerationModeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(accelerationMode));
        }
Пример #3
0
        // [FromBody]dynamic AccelerationMode
        public async Task <IActionResult> PostAddAccelerationModeApi([FromBody] AccelerationMode AccelerationMode)
        {
            Console.WriteLine(AccelerationMode);
            _context.Add(AccelerationMode);
            await _context.SaveChangesAsync();

            // return Json(_context.AccelerationMode.Single(a => a.Capacity == AccelerationMode.Capacity));
            return(Json("Success"));
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("AccelerationModeId,Capacity,Type,Price,Weight,RunningCost,Range")] AccelerationMode accelerationMode)
        {
            if (ModelState.IsValid)
            {
                _context.Add(accelerationMode);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(accelerationMode));
        }