public async Task <IActionResult> PutService(int id, Service service) { if (id != service.Id) { return(BadRequest()); } _context.Entry(service).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ServiceExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> ActivateUser(int UserId) { var user = _context.User.Find(UserId); if (user == null) { return(BadRequest("User Not Found!")); } user.Status = (int)Models.Enums.UserTypesStatus.Active; try { _context.Entry(user).State = EntityState.Modified; await _context.SaveChangesAsync(); } catch (Exception e) { BadRequest("Error!"); } return(Ok(user)); }
public async Task <IActionResult> EditOrder(int id, Order order) { if (id != order.Id) { return(BadRequest()); } _context.Entry(order).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult> ChangeOfferStatus(int id, int status) { var offer = _context.OrderOffer.Find(id); var order = _context.Order.Find(offer.OrderId); if (offer == null) { return(BadRequest("Offer Not Found !")); } offer.Status = status; // Accepted try { _context.Entry(offer).State = EntityState.Modified; await _context.SaveChangesAsync(); switch (offer.Status) { case (int)Models.Enums.OfferStatus.Accepted: notificationProvider.CreateNewNotification(order.UserId, offer.UserId, NotificationTemplates.AcceptOffer, "order-details/" + order.Id); orderProcesses.CloseOrder(offer.OrderId, (int)Models.Enums.OrderStatus.Served); break; case (int)Models.Enums.OfferStatus.Rejected: notificationProvider.CreateNewNotification(order.UserId, offer.UserId, NotificationTemplates.RejectOffer, "order-details/" + order.Id); break; } } catch (Exception e) { return(BadRequest("Error !")); } return(Ok(offer)); }
public async Task <ActionResult <Report> > PostReport(int id, [FromBody] Report report) { report.ReportedUser = id; try { _context.Report.Add(report); await _context.SaveChangesAsync(); } catch (Exception e) { throw; } return(CreatedAtAction("GetReport", new { id = report.Id }, report)); }
public async Task <ActionResult <Rating> > PostRating(int id, [FromBody] Rating rating) { rating.RatedUser = id; _context.Rating.Add(rating); await _context.SaveChangesAsync(); return(CreatedAtAction("GetRating", new { id = rating.Id }, rating)); }