//Get Activites/SaveActivity/3
        //zapisywanie sie na zajęcia
        public ActionResult SaveActivity(int id)
        {
            //wyszukanie aktywnsci na która chce sie zapisac
            var acti = db.Activites.Where(n => n.ID == id);

            Activites activites = null;

            foreach (var item in acti)
            {
                activites = item;
            }

            //pobranie aktualnie zalogowanego użytkownika
            var prof = db.Profiles.Where(n => n.UserName == User.Identity.Name);

            Profile profile = null;

            foreach (var item in prof)
            {
                profile = item;
            }
            activites.NumberPlaces = activites.NumberPlaces - 1;
            Activites_Profile activiteProfile = new Activites_Profile {
                Profile = profile, ActivitesID = id
            };

            db.Activites_Profile.Add(activiteProfile);
            db.SaveChanges();

            return(RedirectToAction("Index", "Activites"));
        }
        public async Task <ActionResult> BookClassConfirmed(int id, int ClassId) //firstid parameter is memberID
        {
            if (_context.Members.Any(x => x.Id == id))                           //check if that memberID actually exists, else return 404 not found
            {
                var memberid = _context.Members.First(x => x.Id == id);
                var classid  = _context.Classes.First(x => x.Id == ClassId);

                //ar classesbooked = _context.ClassesBooked;

                classid.NumberOfBookings = classid.NumberOfBookings + 1;
                //classid.MemberID.Add(memberid);

                _context.ClassesBooked.Add(new ClassesBooked {
                    ClassID = ClassId, MemberID = id
                });


                _context.SaveChanges();
            }

            else
            {
                throw new HttpException(404, "Something has gone wrong");
            }



            TempData["Message"] = "Your class was successfully booked!";
            return(RedirectToAction("Details", new { id = id }));
        }
Beispiel #3
0
        // Get: zmien status zamówienia - akceptuj -------------------------do poprawy
        public ActionResult Accept(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //wyszkunaie odpowiedniego statusu
            var status = db.Status.Find(1);
            //wyszukanie odpowieniego zamówienia
            var order = db.Order.Find(id);
            //wyszukanie order_pass dla naszego zamówienia
            var order_Pass = db.Order_Pass.Where(n => n.Order.ID == id);

            List <Order_Pass> listOfOrder_Pass = new List <Order_Pass>();

            foreach (var item in order_Pass)
            {
                listOfOrder_Pass.Add(item);
            }

            int daysPass = order.Profile.DayOfPass;

            foreach (var item in listOfOrder_Pass)
            {
                daysPass = daysPass + item.Pass.Time;
            }

            order.Profile.DayOfPass = daysPass;

            order.Status = status;

            db.SaveChanges();

            return(RedirectToAction("Index", "FulFillOrder"));
        }
Beispiel #4
0
        public IHttpActionResult PutCoach(int id, Coach coach)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != coach.Id)
            {
                return(BadRequest());
            }

            db.Entry(coach).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CoachExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #5
0
 public bool Eliminar(string id)
 {
     try
     {
         using (unitOfWork = new UnitOfWork(new GymContext()))
         {
             using (GymContext Context = new GymContext())
             {
                 List <PersonaMedidasGym> p = Context.PersonaMedidasGyms.Select(n => n).Where(l => l.idPersona == id).ToList();
                 foreach (PersonaMedidasGym pe in p)
                 {
                     Context.PersonaMedidasGyms.Remove(pe);
                     Context.SaveChanges();
                 }
                 PersonaGym        per = new PersonaGym();
                 List <PersonaGym> pee = Context.PersonaGyms.Select(n => n).Where(l => l.idPersona == id).ToList();
                 foreach (PersonaGym pe in pee)
                 {
                     Context.PersonaGyms.Remove(pe);
                     Context.SaveChanges();
                 }
             }
             return(true);
         }
     }
     catch (Exception e)
     {
         string a = e.Message;
         return(false);
     }
 }
Beispiel #6
0
 public bool Eliminar(string id)
 {
     try
     {
         using (unitOfWork = new UnitOfWork(new GymContext()))
         {
             using (GymContext Context = new GymContext())
             {
                 InstructorGym        per = new InstructorGym();
                 List <InstructorGym> p   = Context.InstructorGyms.Select(n => n).Where(l => l.idInstructor == id).ToList();
                 foreach (InstructorGym pe in p)
                 {
                     List <LogUsuario> pp = Context.LogUsuarios.Select(n => n).Where(l => l.usuario == pe.usuario).ToList();
                     Context.InstructorGyms.Remove(pe);
                     Context.SaveChanges();
                     foreach (LogUsuario pee in pp)
                     {
                         Context.LogUsuarios.Remove(pee);
                         Context.SaveChanges();
                     }
                 }
             }
             return(true);
         }
     }
     catch (Exception e)
     {
         string a = e.Message;
         return(false);
     }
 }
        public ActionResult DeleteConAjax(Categoria categoria)
        {
            Categoria categoriaFind = _context.Categoria.Find(categoria.IdCategoria);

            _context.Categoria.Remove(categoriaFind);
            _context.SaveChanges();
            return(Json(new { result = true, }));
        }
        public ActionResult DeleteConAjax(Casillero casillero)
        {
            Casillero casilleroFind = _context.Casillero.Find(casillero.IdCasillero);

            _context.Casillero.Remove(casilleroFind);
            _context.SaveChanges();
            return(Json(new { result = true, }));
        }
Beispiel #9
0
        public ActionResult DeleteConAjax(Cliente cliente)
        {
            Cliente clienteFind = _context.Cliente.Find(cliente.IdCliente);

            _context.Cliente.Remove(clienteFind);
            _context.SaveChanges();
            return(Json(new { result = true, }));
        }
        public ActionResult DeleteConAjax(Hijo hijo)
        {
            Hijo hijoFind = _context.Hijo.Find(hijo.IdHijo);

            _context.Hijo.Remove(hijoFind);
            _context.SaveChanges();
            return(Json(new { result = true, }));
        }
Beispiel #11
0
        public ActionResult DeleteConAjax(Monedero monedero)
        {
            Monedero monederoFind = _context.Monedero.Find(monedero.IdMonedero);

            _context.Monedero.Remove(monederoFind);
            _context.SaveChanges();
            return(Json(new { result = true, }));
        }
Beispiel #12
0
        public ActionResult DeleteConAjax(Proveedor proveedor)
        {
            Proveedor proveedorFind = _context.Proveedor.Find(proveedor.IdProveedor);

            _context.Proveedor.Remove(proveedorFind);
            _context.SaveChanges();
            return(Json(new { result = true, }));
        }
Beispiel #13
0
        public ActionResult DeleteConAjax(Producto producto)
        {
            Producto productoFind = _context.Producto.Find(producto.IdProducto);

            _context.Producto.Remove(productoFind);
            _context.SaveChanges();
            return(Json(new { result = true, }));
        }
Beispiel #14
0
 public ActionResult EditConAjax(ClaseGym claseGym)
 {
     if (ModelState.IsValid)
     {
         _context.SaveChanges();
         return(Json(new { result = true }));
     }
     return(Json(new { result = false }));
 }
 public ActionResult EditVali(MatriculaClaseGym matriculaClaseGym)
 {
     if (ModelState.IsValid)
     {
         _context.SaveChanges();
         return(Json(new { result = true }));
     }
     return(Json(new { result = false }));
 }
        public ActionResult Create(Registration registration)
        {
            registration.CreationDate = DateTime.Now;
            registration.GroupID      = Convert.ToInt32(Request.Params["GroupID"]);
            int groupID = registration.GroupID;

            registration.ClientID = this.GetLoggedUser().ClientID;
            int clientID = registration.ClientID;

            registration.Status = Catalog.Status.Active;
            if (registrationRepository.ValidarAbonoActivo(clientID, groupID))
            {
                ModelState.AddModelError("GroupID", "El socio no tiene un abono activo");
                ViewBag.Client = this.GetLoggedUser();
                var group = groupRepository.GetGroupByID(groupID);
                ViewBag.Group = group;
                return(View());
            }
            if (registrationRepository.ValidarNivel(groupID))
            {
                ModelState.AddModelError("GroupID", "No tienes permiso para inscribirte a clases de niveles medios y avanzados, contacta con un profesor");
                ViewBag.Client = this.GetLoggedUser();
                var group = groupRepository.GetGroupByID(groupID);
                ViewBag.Group = group;
                return(View());
            }
            if (registrationRepository.ValidarCupo(groupID))
            {
                ModelState.AddModelError("GroupID", "Esta clase no tiene más cupo");
                ViewBag.Client = this.GetLoggedUser();
                var group = groupRepository.GetGroupByID(groupID);
                ViewBag.Group = group;
                return(View());
            }

            if (registrationRepository.HorarioClase(clientID, groupID))
            {
                ModelState.AddModelError("GroupID", "Horario de clase superpuesto con otra clase");
                ViewBag.Client = this.GetLoggedUser();
                var group = groupRepository.GetGroupByID(groupID);
                ViewBag.Group = group;
                return(View());
            }
            if (ModelState.IsValid)
            {
                groupRepository.AgregarInscripto(groupID);
                groupRepository.DecrementarCupo(groupID);
                groupRepository.Save();
                db.Registrations.Add(registration);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ClientID = new SelectList(db.Clients, "ClientID", "FirstName", registration.ClientID);
            ViewBag.GroupID  = new SelectList(db.Groups, "GroupID", "Name", registration.GroupID);
            return(View(registration));
        }
Beispiel #17
0
        public ActionResult DeleteConAjax(Actividad actividad)
        {
            //string mensaje = "Error al eliminar actividad";
            Actividad actividadFind = _context.Actividad.Find(actividad.IdActividad);

            _context.Actividad.Remove(actividadFind);
            _context.SaveChanges();
            //mensaje = "Actividad elminada!";
            return(Json(new { result = true, }));
        }
Beispiel #18
0
        public void Eliminar(int id)
        {
            var _cliente = entidadCliente.Clientes.Find(id);

            if (_cliente != null)
            {
                entidadCliente.Clientes.Remove(_cliente);
                entidadCliente.SaveChanges();
            }
        }
        public ActionResult DeleteConAjax(Usuarios usuarios)
        {
            //string mensaje = "Error al eliminar actividad";
            Usuarios usuariosFind = _context.Usuarios.Find(usuarios.IdUsuario);

            _context.Usuarios.Remove(usuariosFind);
            _context.SaveChanges();
            //mensaje = "Actividad elminada!";
            return(Json(new { result = true, }));
        }
 public ActionResult Create(Coach coach)
 {
     if (ModelState.IsValid)
     {
         db.Coaches.Add(coach);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(coach));
 }
Beispiel #21
0
        public void Eliminar(int id)
        {
            var _seguimiento = entidadSeguimiento.Seguimientos.Find(id);

            if (_seguimiento != null)
            {
                entidadSeguimiento.Seguimientos.Remove(_seguimiento);
                entidadSeguimiento.SaveChanges();
            }
        }
 public IActionResult Post([FromBody] Comprobante comprobante)
 {
     if (ModelState.IsValid)
     {
         _context.Comprobante.Add(comprobante);
         _context.SaveChanges();
         return(new CreatedAtRouteResult("ultimoComprobante", new { id = comprobante.IdComprobante }, comprobante));
     }
     return(BadRequest(ModelState));
 }
Beispiel #23
0
        public ActionResult Create([Bind(Include = "OfertaID,NumeOferta,Pret")] Oferta oferta)
        {
            if (ModelState.IsValid)
            {
                db.Oferte.Add(oferta);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(oferta));
        }
        public ActionResult Create([Bind(Include = "GymMemberId,StaffId,FirstName,LastName,PhoneNumber,EmailAddress, IsAdmin")] GymMember gymMember)
        {
            if (ModelState.IsValid)
            {
                db.GymMembers.Add(gymMember);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(gymMember));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Floor,Sport")] Room room)
        {
            if (ModelState.IsValid)
            {
                db.Rooms.Add(room);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(room));
        }
Beispiel #26
0
        public ActionResult Create([Bind(Include = "FacilityID,Name,Fees,StartDate,InstructorID,RowVersion")] Facility facility)
        {
            if (ModelState.IsValid)
            {
                db.Facilities.Add(facility);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(facility));
        }
        public ActionResult Create([Bind(Include = "ClientID,NumeClient,Telefon")] Client client)
        {
            if (ModelState.IsValid)
            {
                db.Clienti.Add(client);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(client));
        }
Beispiel #28
0
        public ActionResult Create([Bind(Include = "Id,Name,Age,CoachId")] Client client)
        {
            if (ModelState.IsValid)
            {
                db.Clients.Add(client);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(client));
        }
        public ActionResult Create([Bind(Include = "GymClassTypeId,Name,Description,MaxCapacity,MaxWaitList,DayOfTheWeek,ClassTime")] GymClassType gymClassType)
        {
            if (ModelState.IsValid)
            {
                db.GymClassTypes.Add(gymClassType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(gymClassType));
        }
Beispiel #30
0
        public ActionResult Create([Bind(Include = "ID,LastName,FirstMidName,HireDate")] Trainer trainer)
        {
            if (ModelState.IsValid)
            {
                db.Trainers.Add(trainer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(trainer));
        }