コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            DesarrolloSoftware desarrolloSoftware = db.DesarrolloSoftwares.Find(id);

            db.DesarrolloSoftwares.Remove(desarrolloSoftware);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "ID,nombre,numeroAutores")] DesarrolloSoftware desarrolloSoftware)
 {
     if (ModelState.IsValid)
     {
         db.Entry(desarrolloSoftware).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(desarrolloSoftware));
 }
コード例 #3
0
        public ActionResult CreateDesarrolloSoftware([Bind(Include = "ID,nombre,numeroAutores, autores, autorXDesarrolloSoftware")] DesarolloSoftwareAutor desarrolloSoftwareAutor, HttpPostedFileBase upload)
        {
            try
            {
                DesarrolloSoftware software = new DesarrolloSoftware();
                software.nombre        = desarrolloSoftwareAutor.nombre;
                software.numeroAutores = desarrolloSoftwareAutor.numeroAutores;
                db.DesarrolloSoftwares.Add(software);
                db.SaveChanges();

                PersonaXDesarrolloSoftware personaSoftware = new PersonaXDesarrolloSoftware();
                personaSoftware.id_persona             = Int32.Parse(Session["ID"].ToString());
                personaSoftware.id_desarrollo_software = software.ID;
                db.PersonaXDesarrolloSoftwares.Add(personaSoftware);
                db.SaveChanges();

                for (int i = 0; i < desarrolloSoftwareAutor.numeroAutores; i++)
                {
                    Autor autor = new Autor();
                    autor.nombre            = desarrolloSoftwareAutor.autores[i].nombre;
                    autor.correoElectronico = desarrolloSoftwareAutor.autores[i].correoElectronico;
                    db.Autors.Add(autor);
                    db.SaveChanges();
                    AutorXDesarrolloSoftware autorXdesarrollo = new AutorXDesarrolloSoftware();
                    autorXdesarrollo.id_desarrollo_software = software.ID;
                    autorXdesarrollo.id_autor            = autor.ID;
                    autorXdesarrollo.distribucionAutoria = Convert.ToDecimal(desarrolloSoftwareAutor.autorXDesarrolloSoftware.ElementAt(i).distribucionAutoria);
                    db.AutorXDesarrolloSoftwares.Add(autorXdesarrollo);
                    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);
                    InsertDesarrolloSoftwareDoc(System.Guid.NewGuid(), System.IO.Path.GetFileName(upload.FileName), fullPath, 0, software.ID);
                }
                ViewBag.softAgregado = desarrolloSoftwareAutor.nombre;
                return(View());
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        ViewBag.errorsoft = "Error: " + dbEx;
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
                return(View());
            }
        }
コード例 #4
0
        public ActionResult Create([Bind(Include = "ID,nombre,numeroAutores")] DesarrolloSoftware desarrolloSoftware)
        {
            if (ModelState.IsValid)
            {
                db.DesarrolloSoftwares.Add(desarrolloSoftware);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(desarrolloSoftware));
        }
コード例 #5
0
        // GET: DesarrolloSoftware/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DesarrolloSoftware desarrolloSoftware = db.DesarrolloSoftwares.Find(id);

            if (desarrolloSoftware == null)
            {
                return(HttpNotFound());
            }
            return(View(desarrolloSoftware));
        }