Example #1
0
        public int Add(WorkoutModel aModel)
        {
            int result = 0;

            //await Task.Run(() =>
            //{
            try
            {
                Workout aNew = new Workout
                {
                    Code        = aModel.CodigoWorkout,
                    Name        = aModel.Name,
                    Description = aModel.Description,
                    Active      = true,
                    Parent      = aModel.Parent == 0? null: aModel.Parent,
                    Color       = aModel.Color,
                    DateCreated = DateTime.Now
                };
                context.Workout.Add(aNew);
                context.SaveChanges();
                result = aNew.Id;
            }
            catch (Exception ex)
            {
                result = 0;
            }
            //});
            return(result);
        }
Example #2
0
        public int Add(TrainerModel aModel)
        {
            int result = 0;

            //await Task.Run(() =>
            //{
            try
            {
                Trainer aNew = new Trainer
                {
                    Name        = aModel.Name,
                    Code        = aModel.Code,
                    Description = aModel.Description,
                    IdType      = aModel.Type,
                    Active      = true,
                    DateCreated = DateTime.Now,
                    Finger1     = aModel.Huella1,
                    Finger2     = aModel.Huella2,
                    Price       = aModel.Price,
                    PhotoLink   = aModel.PhotoLink
                };
                context.Trainer.Add(aNew);
                context.SaveChanges();
                result = aNew.Id;
            }
            catch (Exception ex)
            {
                result = 0;
            }
            //});
            return(result);
        }
Example #3
0
        public ActionResult registrarPlan(VmRegistrarPlan vmRegistrarPlan, HttpPostedFileBase file)
        {
            try
            {
                Planes obj = null;
                if (vmRegistrarPlan.planID.HasValue)
                {
                    obj = context.Planes.FirstOrDefault(x => x.PlanID == vmRegistrarPlan.planID);

                    if (file != null && file.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(file.FileName);
                        var path     = Path.Combine(Server.MapPath("~/Content/img"), fileName);
                        file.SaveAs(path);
                        obj.imagen = fileName;
                    }
                    //else
                    //{

                    //    obj.imagen = "portfolio5.jpg";
                    //}
                }
                else
                {
                    obj = new Planes();
                    context.Planes.Add(obj);

                    if (file != null && file.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(file.FileName);
                        var path     = Path.Combine(Server.MapPath("~/Content/img"), fileName);
                        file.SaveAs(path);
                        obj.imagen = fileName;
                    }
                    else
                    {
                        obj.imagen = "portfolio5.jpg";
                    }
                }

                obj.Nombre      = vmRegistrarPlan.nombre;
                obj.Descripcion = vmRegistrarPlan.descripcion;
                obj.Costo       = vmRegistrarPlan.costo;

                obj.EstablecimientoID = ((Asociado)Session["objUsuario"]).EstablecimientoID;
                obj.categoriaID       = vmRegistrarPlan.categoria;

                context.SaveChanges();

                return(RedirectToAction("dashboard"));
            }
            catch (Exception)
            {
                vmRegistrarPlan.Fill(context, null);
                TryUpdateModel(vmRegistrarPlan);
                return(View(vmRegistrarPlan));
            }
        }
        public int Add(ClassScheduleReviewModel aModel)
        {
            int result = 0;

            //await Task.Run(() =>
            //{
            try
            {
                ReviewClassSchedule aNew = new ReviewClassSchedule
                {
                    IdClassSchedule = aModel.IdClassSchedule,
                    Observation     = aModel.Observation,
                    IdStaff         = aModel.IdStaff,
                    IsTrainer       = aModel.IsTrainer,
                    IdTrainer       = aModel.IdTrainer,
                    Members         = aModel.Members,
                    Status          = aModel.Estatus,
                    StartTime       = aModel.Start,
                    EndTime         = aModel.End,
                    DateCreated     = DateTime.Now
                };
                context.ReviewClassSchedule.Add(aNew);
                context.SaveChanges();
                result = aNew.Id;
            }
            catch (Exception ex)
            {
                result = 0;
            }
            //});
            return(result);
        }
Example #5
0
        public ActionResult registrarUsuario(VmLogin vmLogin)
        {
            try
            {
                Cliente cliente = new Cliente();
                cliente.Usuario = vmLogin.usuario;
                cliente.Clave   = vmLogin.clave;
                cliente.Correo  = vmLogin.correo;
                cliente.IDApi   = null;
                cliente.Foto    = "/Content/images/user.png";
                //string imageFile = System.Web.HttpContext.Current.Server.MapPath("~/Content/images/user.png");
                //var srcImage = Image.FromFile(imageFile);
                //var stream = new MemoryStream();
                //srcImage.Save(stream, ImageFormat.Png);
                //cliente.Foto= stream.ToArray();
                cliente.Rol = "User";

                GYMEntities context = new GYMEntities();

                context.Cliente.Add(cliente);
                context.SaveChanges();
                Session["objUsuario"] = cliente;
                Session["rol"]        = "C";
                return(RedirectToAction("gimnacioMapa"));
            }
            catch (Exception ex)
            {
                return(View(vmLogin));
            }
        }
Example #6
0
        public ActionResult loginFB(VmLogin vmLogin)
        {
            Cliente cliente = context.Cliente.FirstOrDefault(x => x.IDApi == vmLogin.FbID);

            if (cliente == null)
            {
                cliente         = new Cliente();
                cliente.Usuario = vmLogin.usuario;
                cliente.Clave   = "";
                cliente.Correo  = vmLogin.correo;
                cliente.IDApi   = vmLogin.FbID;
                cliente.Foto    = vmLogin.imagen;
                //string imageFile = System.Web.HttpContext.Current.Server.MapPath("~/Content/images/user.png");
                //var srcImage = Image.FromFile(imageFile);
                //var stream = new MemoryStream();
                //srcImage.Save(stream, ImageFormat.Png);
                //cliente.Foto= stream.ToArray();
                cliente.Rol = "User";

                GYMEntities context = new GYMEntities();

                context.Cliente.Add(cliente);
                context.SaveChanges();
                Session["objUsuario"] = cliente;
                Session["rol"]        = "C";
                return(RedirectToAction("gimnacioMapa"));
            }

            Session["objUsuario"] = cliente;
            Session["rol"]        = "C";
            return(RedirectToAction("gimnacioMapa"));


            //return View();
        }