Exemple #1
0
        public string ChangePassword(int userId, string newPassword, string oldPassword)
        {
            if (oldPassword == newPassword)
            {
                return("Old password and new password are same");
            }

            LoginCredentials lc = _context.LoginCredentials.Where(x => x.UserId == userId).FirstOrDefault();

            if (lc == null)
            {
                return("Failed to change password ");
            }

            if (!_hasher.ValidatePassword(oldPassword, lc.PasswordHash))
            {
                return("Incorrect old password");
            }

            var hash = _hasher.CreateHash(newPassword);

            lc.PasswordHash = hash;
            _context.Update(lc);
            _context.SaveChanges();
            return("Password changed successfully");
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdPedido,FechaCompra,FechaLlegada,Estado,Importe,Descripcion")] Pedido pedido)
        {
            if (id != pedido.IdPedido)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pedido);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PedidoExists(pedido.IdPedido))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pedido));
        }
Exemple #3
0
        public async Task <IActionResult> Edit(int id, [Bind("IdMonedero,IdCliente,Saldo")] Monedero monedero)
        {
            if (id != monedero.IdMonedero)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(monedero);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MonederoExists(monedero.IdMonedero))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                Thread.Sleep(2000);
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCliente"] = new SelectList(_context.Cliente, "IdCliente", "Apellido1", monedero.IdCliente);
            return(View(monedero));
        }
Exemple #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ExerciseID,Exercise_Name,Planned_Set_Number,Planned_Reps,Planned_Weight")] PlannedWorkout plannedWorkout)
        {
            if (id != plannedWorkout.ExerciseID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(plannedWorkout);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlannedWorkoutExists(plannedWorkout.ExerciseID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(plannedWorkout));
        }
Exemple #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Member_Id,Member_Name,Member_Surname,Phone,Email,JoinedDate")] Member member)
        {
            if (id != member.Member_Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(member);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MemberExists(member.Member_Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(member));
        }
Exemple #6
0
        public async Task <IActionResult> Edit(int id, [Bind("IdProducto,Codigo,Nombre,Descripcion,IdProveedor,Existencia,FechaCadu,IdCategoria,PrecioUnidad")] Producto producto)
        {
            if (id != producto.IdProducto)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(producto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductoExists(producto.IdProducto))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCategoria"] = new SelectList(_context.Categoria, "IdCategoria", "Codigo", producto.IdCategoria);
            ViewData["IdProveedor"] = new SelectList(_context.Proveedor, "IdProveedor", "Descripcion", producto.IdProveedor);
            return(View(producto));
        }
Exemple #7
0
        public async Task <IActionResult> Edit(int id, [Bind("Staff_id,Staff_Name,Staff_Surname,Gender,Email")] Staff staff)
        {
            if (id != staff.Staff_id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(staff);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StaffExists(staff.Staff_id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(staff));
        }
Exemple #8
0
        public async Task <IActionResult> Edit(int id, [Bind("UserId,Username")] Users users)
        {
            if (id != users.UserId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(users);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsersExists(users.UserId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(users));
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdUsuario,NombreUsuario,Contraseña,FechaCreacion,Activo,ConfirmarContraseña,IdRole")] Usuarios usuarios)
        {
            if (id != usuarios.IdUsuario)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(usuarios);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsuariosExists(usuarios.IdUsuario))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                Thread.Sleep(1000);
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdRole"] = new SelectList(_context.Roles, "IdRole", "NombreRole", usuarios.IdRole);
            return(View(usuarios));
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdHijo,Identificacion,Nombre,Apellido1,Apellido2,FechaDeNac")] Hijo hijo)
        {
            if (id != hijo.IdHijo)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(hijo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HijoExists(hijo.IdHijo))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                Thread.Sleep(1000);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(hijo));
        }
Exemple #11
0
        public string ChangePassword(int userId, string newPassword, string oldPassword)
        {
            LoginCredentials lc = _context.LoginCredentials.Where(x => x.UserId == userId && x.PasswordHash == oldPassword).FirstOrDefault();

            if (lc != null)
            {
                lc.PasswordHash = newPassword;
                _context.Update(lc);
                _context.SaveChanges();
                return("Password changed successfully");
            }
            else
            {
                return("Failed to change password ");
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("Services_Id,Member_Id,Staff_Id,Name,Description,Price")] Service service)
        {
            if (id != service.Services_Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(service);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ServiceExists(service.Services_Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Member_Id"] = new SelectList(_context.Members, "Member_Id", "Email", service.Member_Id);
            ViewData["Staff_Id"]  = new SelectList(_context.Staffs, "Staff_id", "Email", service.Staff_Id);
            return(View(service));
        }
Exemple #13
0
        public async Task <IActionResult> Edit(int id, [Bind("IdProveedor,Identificacion,NombreProducto,Descripcion,NombreRepresentante,Telefono,Email,Estado")] Proveedor proveedor)
        {
            if (id != proveedor.IdProveedor)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(proveedor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProveedorExists(proveedor.IdProveedor))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                Thread.Sleep(1000);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(proveedor));
        }
Exemple #14
0
        public async Task <IActionResult> Edit(int id, [Bind("StaffID,LastName,FirstName,Occupation,OrganizationName,Address,PhoneNumber")] Staff staff)
        {
            if (id != staff.StaffID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(staff);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StaffExists(staff.StaffID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(staff));
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdActividad,Nombre,Descripcion,Duracion")] Actividad actividad)
        {
            if (id != actividad.IdActividad)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(actividad);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ActividadExists(actividad.IdActividad))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(actividad));
        }
        public async Task <IActionResult> Edit(int id, MembershipType membershipType)
        {
            if (id != membershipType.MembershipTypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(membershipType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MembershipTypeExists(membershipType.MembershipTypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(membershipType));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Exercise_Name,Exercise_Description")] Exercise exercise)
        {
            if (id != exercise.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(exercise);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExerciseExists(exercise.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(exercise));
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdCliente,Identificacion,Nombre,Apellido1,Apellido2,FechaNac,Telefono,Direccion,Email,Estado,Sexo,Casillero,IdTarifa")] Cliente cliente)
        {
            if (id != cliente.IdCliente)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cliente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClienteExists(cliente.IdCliente))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
Exemple #19
0
        public async Task <IActionResult> Edit(int id, [Bind("CategoryId,CategoryName")] Categories categories)
        {
            if (id != categories.CategoryId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categories);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoriesExists(categories.CategoryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(categories));
        }
Exemple #20
0
        public async Task <IActionResult> Edit(int id, [Bind("IdClaseGuarderia,HoraInicio,HoraFin,Fecha,Cupo,Duracion,Estado")] ClaseGuarderia claseGuarderia)
        {
            if (id != claseGuarderia.IdClaseGuarderia)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(claseGuarderia);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClaseGuarderiaExists(claseGuarderia.IdClaseGuarderia))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                Thread.Sleep(1000);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(claseGuarderia));
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdEmpleado,Identificacion,Nombre,Apellido1,Apellido2,FechaNac,Telefono,Direccion,Email,Sexo,Area,TipoDeEmp,NumeroSocial,NumeroBancario,Ccss,Profesion,FechaContrato,Estado")] Empleado empleado)
        {
            if (id != empleado.IdEmpleado)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(empleado);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmpleadoExists(empleado.IdEmpleado))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(empleado));
        }
Exemple #22
0
        public async Task <IActionResult> Edit(int id, [Bind("Membership_Id,Staff_Id,Member_Id,StartDate,EndDate,Total")] Membership membership)
        {
            if (id != membership.Membership_Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(membership);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MembershipExists(membership.Membership_Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(membership));
        }
Exemple #23
0
        public async Task <IActionResult> Edit(int id, [Bind("IdSala,NombreSala,Descripcion,Estado")] Sala sala)
        {
            if (id != sala.IdSala)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sala);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SalaExists(sala.IdSala))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                Thread.Sleep(1000);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(sala));
        }
Exemple #24
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ClassName,ClassSize,NumberOfBookings")] Classes classes)
        {
            if (id != classes.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(classes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClassesExists(classes.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(classes));
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdCasillero,Descripcion")] Casillero casillero)
        {
            if (id != casillero.IdCasillero)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(casillero);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CasilleroExists(casillero.IdCasillero))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                Thread.Sleep(1000);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(casillero));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ExerciseId,ExerciseName,Duration,CategoryId")] Exercise exercise)
        {
            if (id != exercise.ExerciseId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(exercise);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExerciseExists(exercise.ExerciseId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "CategoryId", exercise.CategoryId);
            return(View(exercise));
        }
Exemple #27
0
        public async Task <IActionResult> Edit(int id, [Bind("IdDetalles,IdPedido,IdProducto,IdCategoria,IdProveedor,PrecioUnidad,UnidadesSolicitadas,FechaCaducidad")] DetallesPedido detallesPedido)
        {
            if (id != detallesPedido.IdDetalles)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(detallesPedido);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DetallesPedidoExists(detallesPedido.IdDetalles))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCategoria"] = new SelectList(_context.Categoria, "IdCategoria", "Codigo", detallesPedido.IdCategoria);
            ViewData["IdPedido"]    = new SelectList(_context.Pedido, "IdPedido", "Estado", detallesPedido.IdPedido);
            ViewData["IdProducto"]  = new SelectList(_context.Producto, "IdProducto", "Codigo", detallesPedido.IdProducto);
            ViewData["IdProveedor"] = new SelectList(_context.Proveedor, "IdProveedor", "Descripcion", detallesPedido.IdProveedor);
            return(View(detallesPedido));
        }
Exemple #28
0
        public Gym UpdateGym(int gymId, GymDto dto)
        {
            Gym g = _context.Gyms.Where(x => x.GymId == gymId).FirstOrDefault();

            if (g == null)
            {
                return(null);
            }
            g.Name             = dto.Name;
            g.Email            = dto.Email;
            g.StreetAdress     = dto.StreetAdress;
            g.PostalCode       = dto.PostalCode;
            g.City             = dto.City;
            g.MaxPeople        = dto.MaxPeople;
            g.OperationalHours = dto.OperationalHours;
            g.PhoneNumber      = dto.PhoneNumber;
            _context.Update(g);
            _context.SaveChanges();
            return(g);
        }
Exemple #29
0
        public TrainingClass UpdateTrainingClass(int trainingClassId, TrainingClassDto dto)
        {
            TrainingClass t = _context.TrainingClasses.Where(x => x.TrainingClassId == trainingClassId).FirstOrDefault();

            if (t == null)
            {
                return(null);
            }

            t.Name        = dto.Name;
            t.GymId       = dto.GymId;
            t.MaxPeople   = dto.MaxPeople;
            t.TrainerId   = dto.TrainerId;
            t.Description = dto.Description;
            t.Start       = dto.Start;
            t.End         = dto.End;
            _context.Update(t);
            _context.SaveChanges();
            return(t);
        }
Exemple #30
0
        public async Task <IActionResult> Edit(int id, [Bind("IdClaseGym,IdSala,HoraInicio,HoraFinal,Fecha,Cupo,IdActividad,IdEmpleado,Estado")] ClaseGym claseGym)
        {
            if (id != claseGym.IdClaseGym)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(claseGym);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClaseGymExists(claseGym.IdClaseGym))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                Thread.Sleep(1000);
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdActividad"] = new SelectList(_context.Actividad, "IdActividad", "Nombre", claseGym.IdActividad);
            ViewData["IdEmpleado"]  = _context.Empleado
                                      .Where(e => e.IdEmpleado == claseGym.IdEmpleado)
                                      .Select(e => new SelectListItem
            {
                Text  = e.Nombre + " " + e.Apellido1,
                Value = e.IdEmpleado.ToString()
            });
            //ViewData["IdEmpleado"] = new SelectList(_context.Empleado, "IdEmpleado", "Apellido1", claseGym.IdEmpleado);
            ViewData["IdSala"] = new SelectList(_context.Sala, "IdSala", "NombreSala", claseGym.IdSala);
            return(View(claseGym));
        }