Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Secreto secreto = db.Secretoes.Find(id);

            db.Secretoes.Remove(secreto);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
 public ActionResult Edit([Bind(Include = "ID,nombre")] Secreto secreto)
 {
     if (ModelState.IsValid)
     {
         db.Entry(secreto).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(secreto));
 }
Esempio n. 3
0
 //borra
 public async Task BorrarSecreto(Secreto secreto)
 {
     try
     {
         tareaContext.Secretos.Remove(secreto);
         await tareaContext.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Esempio n. 4
0
 //escribe
 public async Task <Secreto> AgregarSecreto(Secreto secreto)
 {
     try
     {
         tareaContext.Secretos.Add(secreto);
         await tareaContext.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(secreto);
 }
Esempio n. 5
0
        // GET: Secreto/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Secreto secreto = db.Secretoes.Find(id);

            if (secreto == null)
            {
                return(HttpNotFound());
            }
            return(View(secreto));
        }
Esempio n. 6
0
 //edita
 public async Task <Secreto> EditarSecreto(Secreto secreto)
 {
     try
     {
         var SecretoExistete = tareaContext.Secretos.FirstOrDefault(a => a.Id == secreto.Id);
         if (SecretoExistete != null)
         {
             tareaContext.Update(secreto);
             await tareaContext.SaveChangesAsync();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(secreto);
 }
Esempio n. 7
0
        public ActionResult CreateSecreto([Bind(Include = "ID,nombre")] Secreto secreto, HttpPostedFileBase upload)
        {
            try
            {
                db.Secretoes.Add(secreto);
                db.SaveChanges();

                PersonaXSecreto personaSecreto = new PersonaXSecreto();
                personaSecreto.id_persona = Int32.Parse(Session["ID"].ToString());
                personaSecreto.id_secreto = secreto.ID;
                db.PersonaXSecretoes.Add(personaSecreto);
                db.SaveChanges();

                if (upload != null)
                {
                    upload.SaveAs(Path.Combine(Server.MapPath("~/App_Data/uploads"), upload.FileName));
                    string fullPath = Path.Combine(Server.MapPath("~/App_Data/uploads"), upload.FileName);
                    InsertParticipacionCongresoaDoc(System.Guid.NewGuid(), System.IO.Path.GetFileName(upload.FileName), fullPath, secreto.ID);
                }

                ViewBag.secretoAgregado = secreto.nombre;
                return(View());
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        ViewBag.errorSecreto = "Error: " + dbEx;
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
                return(View());
            }
        }