public async Task <IActionResult> PutUsers(int id, Users users) { if (id != users.UsersId) { return(BadRequest()); } _context.Entry(users).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UsersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAppraise(int id, Appraise appraise) { if (id != appraise.AppraiseId) { return(BadRequest()); } _context.Entry(appraise).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AppraiseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutOrders(int id, Orders orders) { _logger.LogInformation("修改支付状态,订单编号:" + id); if (id != orders.OrdersId) { _logger.LogInformation("修改支付状态失败,订单编号:" + id); return(BadRequest()); } _context.Entry(orders).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrdersExists(id)) { return(NotFound()); } else { throw; } } _logger.LogInformation("修改支付状态成功,订单编号:" + id); return(NoContent()); }
public async Task <IActionResult> PutCar(int id, Car car) { if (id != car.CarId) { return(BadRequest()); } _context.Entry(car).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPhoto(int id, Photo photo) { if (id != photo.PhotoId) { return(BadRequest()); } _context.Entry(photo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhotoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutOrdersDetail(int id, OrdersDetail ordersDetail) { if (id != ordersDetail.OrdersDetailId) { return(BadRequest()); } _context.Entry(ordersDetail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrdersDetailExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutDelivery(int id, Delivery delivery) { if (id != delivery.DeliveryId) { return(BadRequest()); } _context.Entry(delivery).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeliveryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("AdminUsersId,UserName,Pwd,Role")] AdminUser adminUser) { if (ModelState.IsValid) { _context.Add(adminUser); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(adminUser)); }
public async Task <IActionResult> Calculate([FromBody] CalculateDto calcDto) { var message = _changeService.Calc(calcDto.AmountPaid, calcDto.TotalAmountToPay); if (!_changeService.IsValid) { return(BadRequest(_changeService.GetErrors)); } var historyEntry = new ChangeHistory(_changeService.TotalChanged()); foreach (var(value, quantity) in _changeService.Notes) { var historyEntryItem = new ChangeHistoryItem(ECurrencyType.Note, quantity, value); historyEntry.AddItem(historyEntryItem); } foreach (var(value, quantity) in _changeService.Coins) { var historyEntryItem = new ChangeHistoryItem(ECurrencyType.Coin, quantity, value); historyEntry.AddItem(historyEntryItem); } await _context.ChangeHistories.AddAsync(historyEntry); await _context.SaveChangesAsync(); return(Ok(message)); }
public async Task <ActionResult> AddGoods(Product product)//添加商品 { if (!ReLogin()) { return(RedirectToAction("Index", "Login")); } product.PostTime = DateTime.Now; _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction("GoodsManage", "Home")); }