/// <summary>
        /// Function to delete entity whose primary key is passes.
        /// </summary>
        /// <param name="pk">Primary key of entity to be deleted</param>
        /// <param name="context">context to maintain transaction</param>
        public void Delete(object pk, AgroAppEntities context)
        {
            DbSet <T> table    = context.Set <T>();
            T         existing = table.Find(pk);

            context.Entry(existing).State = EntityState.Deleted;
        }
        /// <summary>
        /// Function to update entity.
        /// </summary>
        /// <param name="entity">entity to be updated</param>
        /// <param name="context">context to maintain transaction</param>
        public void Update(T entity, AgroAppEntities context)
        {
            DbSet <T> table = context.Set <T>();

            table.Attach(entity);
            context.Entry(entity).State = EntityState.Modified;
        }
 public ActionResult Edit([Bind(Include = "PlantaId,NombrePlanta,SemanasCosecha")] Planta planta)
 {
     if (ModelState.IsValid)
     {
         db.Entry(planta).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(planta));
 }
 public ActionResult Edit([Bind(Include = "TipoVariableCuidadoId,NombreTipoVariableCuidado")] TipoVariableCuidado tipoVariableCuidado)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tipoVariableCuidado).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tipoVariableCuidado));
 }
Exemple #5
0
 public ActionResult Edit([Bind(Include = "UsuarioId,Nombre,Apellido,Cedula,NombreUsuario,Permiso,Clave")] Usuario usuario)
 {
     if (ModelState.IsValid)
     {
         db.Entry(usuario).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(usuario));
 }
 public ActionResult Edit([Bind(Include = "ModuloId,PlantaId,NumeroPlantas,FechaSiembra,VariablesAmbienteId,FechaEstimadaCosecha,FechaRealCosecha,SolucionNutricional")] Modulo modulo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(modulo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PlantaId = new SelectList(db.Planta, "PlantaId", "NombrePlanta", modulo.PlantaId);
     return(View(modulo));
 }
 public ActionResult Edit([Bind(Include = "VariableAmbienteId,ModuloId,TipoVariableAmbienteId,Valor,TimeTag")] VariableAmbiente variableAmbiente)
 {
     if (ModelState.IsValid)
     {
         db.Entry(variableAmbiente).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ModuloId = new SelectList(db.Modulo, "ModuloId", "ModuloId", variableAmbiente.ModuloId);
     ViewBag.TipoVariableAmbienteId = new SelectList(db.TipoVariableAmbiente, "TipoVariableAmbienteId", "NombreTipoVariableAmbiente", variableAmbiente.TipoVariableAmbienteId);
     return(View(variableAmbiente));
 }
 public ActionResult Edit([Bind(Include = "VariableControlId,PlantaId,TipoVariableAmbienteId,VariableControl")] VariablesControl variablesControl)
 {
     if (ModelState.IsValid)
     {
         db.Entry(variablesControl).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PlantaId = new SelectList(db.Planta, "PlantaId", "NombrePlanta", variablesControl.PlantaId);
     ViewBag.TipoVariableAmbienteId = new SelectList(db.TipoVariableAmbiente, "TipoVariableAmbienteId", "NombreTipoVariableAmbiente", variablesControl.TipoVariableAmbienteId);
     return(View(variablesControl));
 }
Exemple #9
0
 public ActionResult Edit([Bind(Include = "VariablesCuidadoId,TipoVariableCuidadoId,ValorCuidado,PlantaId")] VariableCuidado variableCuidado)
 {
     if (ModelState.IsValid)
     {
         db.Entry(variableCuidado).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PlantaId = new SelectList(db.Planta, "PlantaId", "NombrePlanta", variableCuidado.PlantaId);
     ViewBag.TipoVariableCuidadoId = new SelectList(db.TipoVariableCuidado, "TipoVariableCuidadoId", "NombreTipoVariableCuidado", variableCuidado.TipoVariableCuidadoId);
     return(View(variableCuidado));
 }
 /// <summary>
 /// Function to update entity.
 /// </summary>
 /// <param name="entity">entity to be updated</param>
 public string Update(T entity)
 {
     try
     {
         using (AgroAppEntities context = BaseContext.GetDbContext())
         {
             DbSet <T> table = context.Set <T>();
             table.Attach(entity);
             context.Entry(entity).State = EntityState.Modified;
             context.SaveChanges();
             return(string.Empty);
         }
     }
     catch (Exception ex)
     {
         return(CommonHelper.GetErrorMessage(ex));
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="pk">Primary key of entity to be deleted</param>
 public string Delete(object pk)
 {
     try
     {
         using (AgroAppEntities context = BaseContext.GetDbContext())
         {
             DbSet <T> table    = context.Set <T>();
             T         existing = table.Find(pk);
             context.Entry(existing).State = EntityState.Deleted;
             context.SaveChanges();
             return(string.Empty);
         }
     }
     catch (Exception ex)
     {
         return(CommonHelper.GetDeleteException(ex));
     }
 }