public ActionResult SetState(int id, RentalState?state, bool redirectToIndex = false) { if (state == null) { return(BadRequest()); } var renting = this.RepositoriesFactory.Rentings.GetById(id); if (renting == null) { return(NotFound()); } renting.State = state.Value; RepositoriesFactory.SaveChanges(); if (state == RentalState.Canceled) { var result = this.sender.SendRentingCanceled(renting, this.CurrentUser, this.MicrosoftAccessToken).Result; } if (redirectToIndex) { return(RedirectToAction("Index", "Home")); } return(Content("OK")); }
public ActionResult Edit(RentalEditorViewModel postedModel) { if (ModelState.IsValid) { postedModel.UpdateEntity(this.Rental); RepositoriesFactory.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View(postedModel)); }
private async Task TryAddRole(AdminInvite link, User user) { if (link != null) { if (link.WillBeAdmin) { await this.userManager.AddToRoleAsync(user, RoleType.Administrator.ToString()); } if (link.WillBeEmployee) { await this.userManager.AddToRoleAsync(user, RoleType.Employee.ToString()); } link.IsRedeemed = true; RepositoriesFactory.SaveChanges(); } }