Example #1
0
        public ActionResult Edit(string id, FormCollection collection, HttpPostedFileBase file)
        {
            try
            {
                // TODO: Add update logic here

                GrupoCEN gru = new GrupoCEN();

                GrupoEN grupoEN = gru.ReadOID(id);

                string fileName = grupoEN.Imagen;
                if (file != null && file.ContentLength > 0)
                {
                    fileName = file.FileName;
                    string path = "";
                    // extract only the fielname
                    fileName = User.Identity.GetUserName() + Path.GetFileName(file.FileName);
                    // store the file inside ~/App_Data/uploads folder
                    path = Path.Combine(Server.MapPath("~/Images/Uploads"), fileName);
                    //string pathDef = path.Replace(@"\\", @"\");
                    file.SaveAs(path);
                    fileName = "/Images/Uploads/" + fileName;
                }



                bool acepta = grupoEN.AceptaMiembros;
                if (!string.IsNullOrEmpty(collection["AceptaMiembros"]))
                {
                    string[] check  = collection["AceptaMiembros"].Split(',');
                    bool     checkB = Convert.ToBoolean(check[0]);
                    acepta = checkB;
                }

                string descripcion = grupoEN.Descripcion;
                if (!string.IsNullOrEmpty(collection["Descripcion"]))
                {
                    descripcion = collection["Descripcion"];
                }

                gru.Modify(p_Grupo_OID: id, p_descripcion: descripcion, p_imagen: fileName, p_aceptaMiembros: acepta);

                return(RedirectToRoute(new
                {
                    controller = "Grupo",
                    action = "Details",
                    id = id,
                }));
            }
            catch
            {
                return(View());
            }
        }