Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
        public ActionResult Edit(RentalEditorViewModel postedModel)
        {
            if (ModelState.IsValid)
            {
                postedModel.UpdateEntity(this.Rental);
                RepositoriesFactory.SaveChanges();

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

            return(View(postedModel));
        }
Exemplo n.º 3
0
        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();
            }
        }