Example #1
0
        internal static bool CrearCultivo(string laPlanta, string laHuerta, DateTime fechaSiembraSelec, string idCultivo)
        {
            //falta cul_FinSiembra == comienzo de riego
            var finSiembra = fechaSiembraSelec.AddDays(2);
            //falta cul_finCosecha
            var finCosecha  = finSiembra.AddDays(50);
            var plantaPadre = new PlantaModel().buscarPorId(laPlanta);

            var nuevoCultivo = new CultivoModel
            {
                IdCultivo     = idCultivo,
                FinSiembra    = finSiembra,
                FinCosecha    = finCosecha,
                IniciaCultivo = fechaSiembraSelec,
                NombreCultivo = plantaPadre.nombre
            };

            var ok = nuevoCultivo.CrearCultivo(nuevoCultivo, laPlanta, laHuerta);

            if (ok)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public async Task <ActionResult> Register(RegisterViewModel model, int planta, int roles)
        {
            PlantaModel plantaModel = new PlantaModel();

            ViewData["plantas"] = plantaModel.obtenerPlantas();

            RolModel rolModel = new RolModel();

            ViewData["roles"] = new SelectList(rolModel.obtenerRol(), "Id_Rol", "Nombre");

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Name, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                    // Para obtener más información sobre cómo habilitar la confirmación de cuenta y el restablecimiento de contraseña, visite http://go.microsoft.com/fwlink/?LinkID=320771
                    // Enviar correo electrónico con este vínculo
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirmar cuenta", "Para confirmar la cuenta, haga clic <a href=\"" + callbackUrl + "\">aquí</a>");
                    plantaModel.UsuarioPlanta(model.Email, planta, roles, model.Password);
                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // Si llegamos a este punto, es que se ha producido un error y volvemos a mostrar el formulario
            return(View(model));
        }
Example #3
0
        internal static List <PlantaModel> obtenerByCategoria(int itemSelec)
        {
            var    dbPlanta    = new PlantaModel();
            string CategoriaID = dbPlanta.obtenerIdCategoria(itemSelec);

            return(dbPlanta.obtenerById(CategoriaID));
        }
Example #4
0
        }//

        public ActionResult ObtenerVatis(int id_planta)
        {
            Models.VatihorimetroModel vatiModel = new Models.VatihorimetroModel();
            PlantaModel planta = new PlantaModel();

            return(Json(vatiModel.obtenerVatihorimetroPorPlanta(id_planta), JsonRequestBehavior.AllowGet));
        }//end mostrar vista
        }//EliminarInspeccion

        public ActionResult LlenarInspeccionView()
        {
            InspeccionModel inspeccionModel = new InspeccionModel();
            ViewData["inspecciones"] = new SelectList(inspeccionModel.obtenerInspeccion(), "id_Inspeccion", "Nombre");
            PlantaModel plantaModel = new PlantaModel();
            ViewData["plantas"] = plantaModel.obtenerPlantas();
            return View();
        }//RegistrarInspeccionView
        }//obtenerEvaluacion

        public ActionResult ActualizarHallazgoView()
        {
            InspeccionModel inspeccionModel = new InspeccionModel();
            ViewData["inspecciones"] = new SelectList(inspeccionModel.obtenerInspeccion(), "id_Inspeccion", "Nombre");
            PlantaModel plantaModel = new PlantaModel();
            ViewData["plantas"] = plantaModel.obtenerPlantas();
            return View();
        }//actualizarhallazgoview
Example #7
0
        }//edn resgistrar

        public ActionResult ActualizarConsumoElectricoView()
        {
            Models.PlantaModel palnta = new Models.PlantaModel();
            PlantaModel        planta = new PlantaModel();
            String             email  = Session["email"].ToString();
            int id_planta             = planta.obtenerUsuarioPlanta(email);

            ViewData["plantas"]     = new SelectList(palnta.obtenerPlantas(), "id", "nombre");
            ViewData["MesAnterior"] = (System.DateTime.Now.Month) - 1;
            return(View());
        }//end registrar
        public ActionResult Register()
        {
            PlantaModel plantaModel = new PlantaModel();

            ViewData["plantas"] = plantaModel.obtenerPlantas();

            RolModel rolModel = new RolModel();

            ViewData["roles"] = new SelectList(rolModel.obtenerRol(), "Id_Rol", "Nombre");

            return(View());
        }
        }//end mostrar vista

        public ActionResult RegistrarConsumoAguaAntiguoView()
        {
            Models.HidrometroModel hidroModel = new Models.HidrometroModel();
            PlantaModel planta = new PlantaModel();
            String email = Session["email"].ToString();
            if (email != null)
            {
                int id_planta = planta.obtenerUsuarioPlanta(email);
                ViewData["Hidros"] = hidroModel.obtenerHidrometrosPorPlanta(id_planta);
                return View();
            }else{
                return View();
            }
       } 
 public ActionResult RegistrarPlantaView(Entity.Planta planta)
 {
         if (ModelState.IsValid)
         {
             PlantaModel sdb = new PlantaModel();
             if (sdb.crearPlanta(planta))
             {
                 TempData["success"] = "true";
                 return RedirectToAction("RegistrarPlantaView");
             }
             else
             {
                 TempData["error"] = "false";
             }
         }
         return View();
 }//Registrar Planta
Example #11
0
        }//end mostrar vista

        public ActionResult RegistrarConsumoElectricoAntiguoView()
        {
            VatihorimetroModel vatiModel = new VatihorimetroModel();
            PlantaModel        planta    = new PlantaModel();

            String email = Session["email"].ToString();

            if (email != null)
            {
                int id_planta = planta.obtenerUsuarioPlanta(email);
                ViewData["Vatis"] = vatiModel.obtenerVatihorimetroPorPlanta(id_planta);
                return(View());
            }
            else
            {
                return(View());
            }
        }//
Example #12
0
 public ActionResult RegistrarHidrometroView(Entity.Hidrometro hidrometro, int plantas)
 {
         PlantaModel plantaModel = new PlantaModel();
         ViewData["plantas"] = new SelectList(plantaModel.obtenerPlantas(), "id", "nombre");
         if (ModelState.IsValid)
         {
         HidrometroModel sdb = new HidrometroModel();
             if (sdb.crearHidrometro(hidrometro, plantas))
             {
                 TempData["success"] = "true";
                 return RedirectToAction("RegistrarHidrometroView");
             }else
             {
                 TempData["success"] = "true";
                 return View();
             }
         }//end if
         return View();
 }//insertar
        }//Registrar Planta

        public ActionResult EliminarPlanta(int id)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    PlantaModel sdb = new PlantaModel();
                    if (sdb.EliminarPlanta(id))
                    {
                        ViewBag.AlertMsg = "Eliminada";
                    }
                }
                return RedirectToAction("EliminarPlantaView");
            }//end try
            catch
            {
                return RedirectToAction("EliminarPlantaView");
            }//catch

        }//Registrar Planta
        }//end mostrar vista

        public ActionResult ObtenerHidros(int id_planta)
        {
            Models.HidrometroModel hidroModel = new Models.HidrometroModel();
            PlantaModel planta = new PlantaModel();
            return Json(hidroModel.obtenerHidrometrosPorPlanta(id_planta),JsonRequestBehavior.AllowGet);
        }//end mostrar vista
        }//index

        public ActionResult EliminarPlantaView()
        {
            PlantaModel plantaModel = new PlantaModel();
            ModelState.Clear();
            return View(plantaModel.obtenerPlantas());
        }