Beispiel #1
0
        public async Task <IActionResult> PutProduct(int id, Product product)
        {
            if (id != product.productid)
            {
                return(BadRequest());
            }

            _context.Entry(product).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #2
0
        public async Task <IActionResult> PutHistoryEvent(int id, HistoryEvent historyEvent)
        {
            if (id != historyEvent.hisevid)
            {
                return(BadRequest());
            }

            _context.Entry(historyEvent).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HistoryEventExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #3
0
        public async Task <IActionResult> PutUser(int id, User user)
        {
            if (id != user.userid)
            {
                return(BadRequest());
            }

            _context.Entry(user).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #4
0
        public async Task <outputSignUp> PutUser(int id, User user)
        {
            outputSignUp output = new outputSignUp();

            //if (id != user.userid)
            //{
            //    return BadRequest();
            //}

            //_context.Entry(user).State = EntityState.Modified;

            //try
            //{
            //    await _context.SaveChangesAsync();
            //}
            //catch (DbUpdateConcurrencyException)
            //{
            //    if (!UserExists(id))
            //    {
            //        return NotFound();
            //    }
            //    else
            //    {
            //        throw;
            //    }
            //}

            try
            {
                _context.Entry(user).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                if (user.userid != 0)
                {
                    //result = user;

                    output.Result  = "OK";
                    output.users   = user;
                    output.Message = "Success";
                }
                else
                {
                    output.Result  = "NG";
                    output.Message = "Fail";
                }
            }
            catch (Exception ex)
            {
                output.Result  = "NG";
                output.Message = ex.ToString();
            }

            return(output);
        }