Esempio n. 1
0
        public void AvanzarPosicion()
        {
            int Caminar = Paso.Next(1, 10);

            if (Caminar < 4)
            {
                _Posicion += 1;
                _accion    = " Salto pequeño ";
            }
            else if (Caminar < 6)
            {
                _Posicion += 9;
                _accion    = " Salto grande ";
            }
            else if (Caminar < 7)
            {
                _Posicion -= 12;
                _accion    = " Resbalon grande ";
            }
            else if (Caminar < 9)
            {
                _Posicion -= 2;
                _accion    = " Resbalon Pequeño ";
            }
            else
            {
                _Posicion += 0;
                _accion    = " Dormido ";
            }
        }
        void ICatalogo.Mostrar(int id)
        {
            Paso entidad = (from o in SesionActual.Instance.getContexto <IglesiaEntities>().Paso where o.PasoId == id select o).FirstOrDefault();

            registroId.Value          = entidad.PasoId;
            registroDescripcion.Value = entidad.Descripcion;
            registroCategoria.Value   = entidad.PasoCategoriaId;
        }
Esempio n. 3
0
        //
        // GET: /Paso/Details/5

        public ActionResult Details(int id)
        {
            Paso pas = null;

            SessionInitialize();
            PasoEN pasEN = new PasoCAD(session).ReadOIDDefault(id);

            pas = new AssemblerPaso().ConvertENToModelUI(pasEN);
            SessionClose();
            return(View(pas));
        }
Esempio n. 4
0
        //
        // GET: /Paso/Create

        public ActionResult Create(int id)
        {
            SessionInitialize();

            Paso pas = new Paso();

            pas.idGymkana = id;
            pas.Numero    = new GymkanaCAD().GetID(id).NumPasos + 1;

            SessionClose();
            return(View(pas));
        }
        void ICatalogo.Guardar(int id, RegistrosHelper.ListaDeRegistrosDeDatos listaDeRegistrosDeDatos)
        {
            Paso entidad = (from o in SesionActual.Instance.getContexto <IglesiaEntities>().Paso where o.PasoId == id select o).FirstOrDefault();

            if (entidad == null)
            {
                entidad = new Paso();
            }

            entidad.Descripcion     = registroDescripcion.Text;
            entidad.PasoCategoriaId = registroCategoria.ObtenerId();
            entidad.Guardar(SesionActual.Instance.getContexto <IglesiaEntities>());
        }
Esempio n. 6
0
        public ActionResult Delete(Paso pas)
        {
            try
            {
                PasoCP cp = new PasoCP();
                cp.BorrarPaso(pas.id);


                return(RedirectToAction("List", "Gymkana"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 7
0
        //
        // GET: /Paso/Edit/5

        public ActionResult Edit(int id)
        {
            Paso pas = null;

            SessionInitialize();
            PasoEN pasen = new PasoCAD(session).ReadOIDDefault(id);

            pas = new AssemblerPaso().ConvertENToModelUI(pasen);
            UsuarioEN usu = new PasoCAD().GetID(id).Gymkana.Usuario;

            if (User.Identity.Name != usu.Nombre && !Roles.IsUserInRole("admin"))
            {
                return(RedirectToAction("Details", new { id = id }));
            }
            SessionClose();
            return(View(pas));
        }
Esempio n. 8
0
        public void AvanzarPosicion()
        {
            int Camina = Paso.Next(1, 11);

            if (Camina < 6)
            {
                _Posicion += 3;
                _accion    = " Paso lento ";
            }
            else if (Camina < 8)
            {
                _Posicion -= 6;
                _accion    = " resbalon ";
            }
            else
            {
                _Posicion += 1;
                _accion    = " Paso Lento ";
            }
        }
Esempio n. 9
0
        public ActionResult Edit(Paso pas)
        {
            try
            {
                PasoCP cp    = new PasoCP();
                PasoEN en    = new PasoCAD().GetID(pas.id);
                MapaEN mapen = new MapaCAD().FiltrarMapaPorPaso(pas.id);

                mapen.Latitud  = pas.Latitud;
                mapen.Longitud = pas.Longitud;
                mapen.Zoom     = pas.Zoom;
                en.Descripcion = pas.Descripcion;

                cp.ModificarPaso(en, mapen);

                return(RedirectToAction("Index", new { id = pas.idGymkana }));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 10
0
        public ActionResult Create(Paso pas)
        {
            try
            {
                UsuarioCAD cad    = new UsuarioCAD();
                GymkanaCP  cp     = new GymkanaCP();
                GymkanaCAD gymcad = new GymkanaCAD();
                PasoEN     en     = new PasoEN();
                MapaEN     mapen  = new MapaEN();
                GymkanaEN  gymen  = gymcad.GetID(pas.id);
                mapen.Latitud  = pas.Latitud;
                mapen.Longitud = pas.Longitud;
                mapen.Zoom     = pas.Zoom;

                en.Descripcion = pas.Descripcion;
                cp.AnadirPaso(en, mapen, gymen);
                return(RedirectToAction("Index", new { id = gymen.ID }));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 11
0
        //public ActionResult Crear(Receta rec, HttpPostedFileBase file, FormCollection datos)
        public ActionResult Crear(Receta rec, HttpPostedFileBase file, int[] canIngrediente, UnidadesEnum[] uniIngrediente, string[] nomIngrediente, int[] numPaso, string[] desPaso)
        {
            string imagesDir = "Images/Uploads";

            string fileName = "", path = "";

            // Verify that the user selected a file
            if (file != null && file.ContentLength > 0)
            {
                // extract only the fielname
                fileName = Path.GetFileName(file.FileName);
                // store the file inside ~/App_Data/uploads folder
                path = Path.Combine(Server.MapPath("~/" + imagesDir), fileName);
                //string pathDef = path.Replace(@"\\", @"\");
                file.SaveAs(path);
            }

            try
            {
                fileName = "/" + imagesDir + "/" + fileName;

                // Parametros por defecto
                rec.FechaCreacion = DateTime.Now;
                rec.Estado        = EnMiNeveraGenNHibernate.Enumerated.EnMiNevera.EstadosEnum.publicado;
                rec.Foto          = fileName;

                // Obtenemos los pasos
                IList <Paso> pasos = new List <Paso>();
                Paso         paso  = null;
                for (int i = 0; i < numPaso.Count(); i++)
                {
                    paso             = new Paso();
                    paso.NumeroPaso  = numPaso[i];
                    paso.Descripcion = desPaso[i];
                    pasos.Add(paso);
                }

                // Obtenemos las lineas de ingrediente
                IList <LineaIngrediente> lineasIng = new List <LineaIngrediente>();
                LineaIngrediente         lin       = null;
                for (int i = 0; i < canIngrediente.Count(); i++)
                {
                    lin                   = new LineaIngrediente();
                    lin.Cantidad          = canIngrediente[i];
                    lin.NombreIngrediente = nomIngrediente[i];
                    lin.Unidad            = uniIngrediente[i];
                    lineasIng.Add(lin);
                }


                SessionInitialize();
                using (var transaction = session.BeginTransaction())
                {
                    // Obtengo el id del usuario
                    int idUsuario = new UsuarioCAD(session).GetByNick(User.Identity.Name).Id;

                    RecetaCAD cad = new RecetaCAD(session);
                    RecetaCEN cen = new RecetaCEN(cad);

                    int idReceta = cen.New_(rec.Nombre, rec.Descripcion, rec.Foto, idUsuario, rec.FechaCreacion, rec.Estado);

                    // Creamos los pasos
                    PasosCAD pasosCad = new PasosCAD(session);
                    PasosCEN pasosCen = new PasosCEN(pasosCad);
                    foreach (Paso p in pasos)
                    {
                        pasosCen.New_(p.Descripcion, idReceta, p.NumeroPaso);
                    }

                    // Creamos las lineas de ingrediente
                    LineaIngredienteCAD lineaIngredienteCad = new LineaIngredienteCAD(session);
                    LineaIngredienteCEN lineaIngredienteCen = new LineaIngredienteCEN(lineaIngredienteCad);

                    IngredienteCAD ingredienteCad = new IngredienteCAD(session);
                    IngredienteEN  ingredienteEn;

                    foreach (LineaIngrediente l in lineasIng)
                    {
                        // por cada linea, si no existe el ingrediente, lo creamos
                        ingredienteEn = ingredienteCad.GetPorNombre(l.NombreIngrediente);
                        if (ingredienteEn == null)
                        {
                            ingredienteEn        = new IngredienteEN();
                            ingredienteEn.Nombre = l.NombreIngrediente;
                            ingredienteEn.Id     = ingredienteCad.New_(ingredienteEn);
                        }

                        lineaIngredienteCen.New_(l.Cantidad, l.Unidad, ingredienteEn.Id, idReceta);
                    }

                    transaction.Commit();
                }
                SessionClose();



                //RecetaCEN cen = new RecetaCEN();

                //// Obtengo el id del usuario
                //int idUsuario = new UsuarioCAD().GetByNick(User.Identity.Name).Id;

                //rec.FechaCreacion = DateTime.Now;
                //rec.Estado = EnMiNeveraGenNHibernate.Enumerated.EnMiNevera.EstadosEnum.publicado;

                //cen.New_(rec.Nombre, rec.Descripcion, fileName, idUsuario, rec.FechaCreacion, rec.Estado);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public bool GuardarPasosPorMiembro(int miembroId, RegistrosHelper.RegistrosDeDatos pasosNuevosYEliminados)
        {
            bool rtn = false;

            if (miembroId > 0 && (pasosNuevosYEliminados.RegistrosNuevosId.Count > 0 || pasosNuevosYEliminados.RegistrosEliminadosId.Count > 0))
            {
                Miembro     miembro = (from o in SesionActual.Instance.getContexto <IglesiaEntities>().Miembro where o.MiembroId == miembroId select o).FirstOrDefault();
                MiembroPaso miembroPaso;

                if (miembro == null)
                {
                    throw new ExcepcionReglaNegocio(Literales.RegistroInexistente);
                }

                //Si tenemos registros nuevos...
                if (pasosNuevosYEliminados.RegistrosNuevosId.Count > 0)
                {
                    //Agregamos los nuevos pasos celulas (siempre y cuando no existan previamente...)
                    foreach (KeyValuePair <int, Dictionary <string, string> > pasoObj in pasosNuevosYEliminados.RegistrosNuevos)
                    {
                        if (!miembro.MiembroPaso.Any(o => o.PasoId == pasoObj.Key && o.Borrado == false))
                        {
                            int cicloId;
                            if (!int.TryParse(pasoObj.Value["CicloId"], out cicloId))
                            {
                                Paso paso = (from o in SesionActual.Instance.getContexto <IglesiaEntities>().Paso where o.PasoId == pasoObj.Key select o).FirstOrDefault();

                                if (paso != null)
                                {
                                    throw new ExcepcionReglaNegocio(string.Format("El paso [{0}] no cuenta con un ciclo valido; favor de corregirlo y volver a intentar.", paso.Descripcion));
                                }
                                else
                                {
                                    throw new ExcepcionReglaNegocio(string.Format("El paso cuyo id es [{0}] es inexistente; favor de corregirlo y volver a intentar.", pasoObj.Key));
                                }
                            }

                            miembroPaso           = new MiembroPaso();
                            miembroPaso.MiembroId = miembroId;
                            miembroPaso.PasoId    = pasoObj.Key;
                            miembroPaso.CicloId   = cicloId;
                            miembro.MiembroPaso.Add(miembroPaso);
                        }
                    }

                    //Guardamos los cambios, antes de eliminar registros
                    miembro.Guardar(SesionActual.Instance.getContexto <IglesiaEntities>());
                }

                //Eliminamos los pasos eliminados
                foreach (int pasoId in pasosNuevosYEliminados.RegistrosEliminadosId)
                {
                    miembroPaso = (from o in SesionActual.Instance.getContexto <IglesiaEntities>().MiembroPaso where o.PasoId == pasoId && o.MiembroId == miembroId && o.Borrado == false select o).FirstOrDefault();
                    if (miembroPaso != null)
                    {
                        miembroPaso.Borrar(SesionActual.Instance.getContexto <IglesiaEntities>());
                    }
                }
            }

            return(rtn);
        }
        void ICatalogo.Borrar(int id)
        {
            Paso entidad = (from o in SesionActual.Instance.getContexto <IglesiaEntities>().Paso where o.PasoId == id select o).FirstOrDefault();

            entidad.Borrar(SesionActual.Instance.getContexto <IglesiaEntities>());
        }