public ActionResult Create()
 {
     AN_Anuncios an = new AN_Anuncios();
     an.ST_Id = 1;
     an.UserId = WebSecurity.CurrentUserId;
     an.AN_Fecha = System.DateTime.Now;
     an.AN_FechaExpiracion = System.DateTime.Now.AddMonths(3);
     ViewBag.SBS_Id = new SelectList(db.SBS_SubCategoriaServicio, "SBS_Id", "SBS_Descripcion");
     ViewBag.ST_Id = new SelectList(db.ST_Estatus, "ST_Id", "ST_Descripcion");
     ViewBag.PA_Id = new SelectList(db.PA_Paises, "PA_Id", "PA_Descripcion");
     ViewBag.UserId = new SelectList(db.UserProfile, "UserId", "UserName");
     ViewBag.CD_Id = new SelectList(db.CD_CategoriaServicio, "CD_Id", "CD_Descripcion");
     return View(an);
 }
        public ActionResult Create(AN_Anuncios an_anuncios)
        {
            if (ModelState.IsValid)
            {
                db.AN_Anuncios.Add(an_anuncios);

                var Anuncio = db.SaveChanges<AN_Anuncios>(an_anuncios);
                if (Anuncio != null)
                {
                    string directorio = System.Configuration.ConfigurationManager.AppSettings["ContenidoMultimedia"];
                    if (!System.IO.Directory.Exists(Server.MapPath(directorio + Anuncio.AN_Id)))
                        System.IO.Directory.CreateDirectory(Server.MapPath(directorio + Anuncio.AN_Id));
                }
                HttpContext.Session["Anuncio"] = Anuncio.AN_Id;
                return PartialView("LoadUplaoder");
            }

            ViewBag.SBS_Id = new SelectList(db.SBS_SubCategoriaServicio, "SBS_Id", "SBS_Descripcion", an_anuncios.SBS_Id);
            ViewBag.ST_Id = new SelectList(db.ST_Estatus, "ST_Id", "ST_Descripcion", an_anuncios.ST_Id);
            ViewBag.UserId = new SelectList(db.UserProfile, "UserId", "UserName", an_anuncios.UserId);
            ViewBag.PA_Id = new SelectList(db.PA_Paises, "PA_Id", "PA_Descripcion", an_anuncios.PA_Id);
            ViewBag.CD_Id = new SelectList(db.CD_CategoriaServicio, "CD_Id", "CD_Descripcion", an_anuncios.CD_Id);
            return View(an_anuncios);
        }
        public ActionResult Edit(AN_Anuncios an_anuncios)
        {
            if (ModelState.IsValid)
            {
                db.Entry(an_anuncios).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.ResourcesCount = an_anuncios.AE_AnunciosExtras.Count;
            an_anuncios.AE_AnunciosExtras = db.AE_AnunciosExtras.Where(c => c.AN_Id == an_anuncios.AN_Id).ToList();

            ViewBag.SBS_Id = new SelectList(db.SBS_SubCategoriaServicio, "SBS_Id", "SBS_Descripcion", an_anuncios.SBS_Id);
            ViewBag.ST_Id = new SelectList(db.ST_Estatus, "ST_Id", "ST_Descripcion", an_anuncios.ST_Id);
            ViewBag.UserId = new SelectList(db.UserProfile, "UserId", "UserName", an_anuncios.UserId);
            ViewBag.PA_Id = new SelectList(db.PA_Paises, "PA_Id", "PA_Descripcion");
            ViewBag.CD_Id = new SelectList(db.CD_CategoriaServicio, "CD_Id", "CD_Descripcion");
            return View(an_anuncios);
        }