コード例 #1
0
        public async Task <bool> ChangePassword(ChangePasswordViewModel model)
        {
            var exitAccount = await AccountDb.AsQueryable().SingleAsync(a => a.Id == model.UserId.ToGuid() && a.Password == model.OldPassword.ToMD5());

            if (!exitAccount.IsNull())
            {
                exitAccount.ChangePassword(model.NewPassword.ToMD5());
                return(AccountDb.Update(exitAccount));
            }

            return(false);
        }
コード例 #2
0
        public async Task <IActionResult> Edit(AccountsEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                Account account = new Account
                {
                    Id          = model.Id,
                    FirstName   = model.FirstName,
                    LastName    = model.LastName,
                    PhoneNumber = model.PhoneNumber,
                    Email       = model.Email,
                    Username    = model.Username,
                    Password    = model.Password,
                    Active      = model.Active,
                    Role        = model.Role,
                    Released    = model.Released,
                    PersonalId  = model.PersonalId,
                    Start       = model.Start
                };

                try
                {
                    context.Update(account);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!context.Accounts.Any(e => e.Id == model.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

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

            return(View(model));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(RoomsEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                Room rooms = new Room
                {
                    Id        = model.Id,
                    Capacity  = model.Capacity,
                    AdultBed  = model.AdultBed,
                    ChildBed  = model.ChildBed,
                    Available = model.Available,
                    Number    = model.Number,
                    RoomType  = model.RoomType
                };

                try
                {
                    context.Update(rooms);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!context.Rooms.Any(e => e.Id == model.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

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

            return(View(model));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(ClientsEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                Client clients = new Client
                {
                    Id                   = model.Id,
                    FirstName            = model.FirstName,
                    LastName             = model.LastName,
                    PhoneNumber          = model.PhoneNumber,
                    Email                = model.Email,
                    Adult                = model.Adult,
                    previousReservations = model.previousReservations
                };

                try
                {
                    context.Update(clients);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!context.Clients.Any(e => e.Id == model.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

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

            return(View(model));
        }