Beispiel #1
0
        public IHttpActionResult PutNews(int id, Dal.Models.News news)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != news.NewsId)
            {
                return(BadRequest());
            }

            db.Entry(news).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NewsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult EditOrder(List <int> slideId, List <int> order)
        {
            for (var i = 0; i < slideId.Count; i++)
            {
                var id       = slideId[i];
                var getSlide = db.SlidesList.SingleOrDefault(x => x.SlideId == id);
                getSlide.Order = order[i];

                db.Entry(getSlide).State = EntityState.Modified;
                db.SaveChanges();
            }

            SetMessage("Se cambio el orden de tus slides exitosamente.", BootstrapAlertTypes.Success);
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public ActionResult Edit(MediaViewModel media)
        {
            if (Request.Cookies["MagazineId"].Value == null)
            {
                SetMessage("Lo sentimos, ha ocurrido un error. Inténtelo de nuevo.", BootstrapAlertTypes.Danger); return(RedirectToAction("Index", "Magazines"));
            }
            int magId = Int32.Parse(Request.Cookies["MagazineId"].Value);

            var user     = UserService.GetCurrentUser();
            var relation = UserService.UserInMagazine(magId, user.UserId);

            if (!relation || !ModelState.IsValid)
            {
                return(RedirectToAction("Index", "Magazines"));
            }

            if (!ModelState.IsValid)
            {
                return(View(media));
            }

            var model = new Media
            {
                Email = media.Email,
                Name  = media.Name,
            };

            db.Entry(model).State = EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Beispiel #4
0
        public IHttpActionResult PutUser(int id, User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != user.UserId)
            {
                return(BadRequest());
            }

            db.Entry(user).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                throw;
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #5
0
        public IHttpActionResult PutMagazine(int id, Magazine magazine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != magazine.MagazineId)
            {
                return(BadRequest());
            }

            db.Entry(magazine).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MagazineExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #6
0
        public ActionResult Edit([Bind(Include = "QuizId,Title,Description")] Quiz quiz)
        {
            if (Request.Cookies["MagazineId"].Value == null)
            {
                SetMessage("Lo sentimos, ha ocurrido un error. Inténtelo de nuevo.", BootstrapAlertTypes.Danger); return(RedirectToAction("Index", "Magazines"));
            }
            int magId = Int32.Parse(Request.Cookies["MagazineId"].Value);

            quiz.CreationDate = DateTime.Now;
            quiz.MagazineId   = magId;

            if (ModelState.IsValid)
            {
                db.Entry(quiz).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(quiz));
        }
Beispiel #7
0
        public HttpResponseMessage PostCategory(Category category)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Faltan datos."));
            }

            if (category.CategoryId != 0)
            {
                db.Entry(category).State = EntityState.Modified;
            }
            else
            {
                db.CategoriesList.Add(category);
            }

            db.SaveChanges();

            return(Request.CreateErrorResponse(HttpStatusCode.OK, "Categoria creada"));
        }
 public ActionResult Edit([Bind(Include = "UserMagazineId,UserId,MagazineId")] UserMagazine userMagazine)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userMagazine).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MagazineId = new SelectList(db.MagazinesList.Include(x => x.User).Where(x => x.User.Email.Equals(UserEmail)), "MagazineId", "Title", userMagazine.MagazineId);
     ViewBag.UserId     = new SelectList(db.UsersList.Where(x => !x.Email.Equals(UserEmail, StringComparison.OrdinalIgnoreCase)), "UserId", "Email", userMagazine.UserId);
     return(View(userMagazine));
 }
        public ActionResult Edit([Bind(Include = "AdCategoryId,Name,Tags,StartDate,EndDate,Active,MagazineId")] AdCategory adCategory)
        {
            if (ModelState.IsValid)
            {
                db.Entry(adCategory).State = EntityState.Modified;
                db.SaveChanges();

                SetMessage("Campaña editada", BootstrapAlertTypes.Success);
                return(RedirectToAction("Index"));
            }

            ViewBag.Keywords = Keywords_GetForAdGroup(db.NewsesList.Where(x => x.Category.MagazineId == adCategory.MagazineId).ToList()).OrderByDescending(x => x.Value);

            SetMessage("Ha ocurrido un error al editar la campaña", BootstrapAlertTypes.Danger);
            return(View(adCategory));
        }
        public ActionResult Edit([Bind(Include = "GaleryId,Title,Description,Alt,MetaDesc,Keywords,Permalink,CreationDate")] Galery galery)
        {
            Galery model = db.GaleriesList.Find(galery.GaleryId);

            model.Alt         = galery.Alt;
            model.Description = galery.Description;
            model.MetaDesc    = galery.MetaDesc;
            model.Title       = galery.Title;
            model.Keywords    = galery.Keywords;

            if (ModelState.IsValid)
            {
                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(galery));
        }
Beispiel #11
0
        public ActionResult Edit(ReportViewModel report)
        {
            if (Request.Cookies["MagazineId"].Value == null)
            {
                SetMessage("Lo sentimos, ha ocurrido un error. Inténtelo de nuevo.", BootstrapAlertTypes.Danger); return(RedirectToAction("Index", "Magazines"));
            }
            int magId = Int32.Parse(Request.Cookies["MagazineId"].Value);

            var user     = UserService.GetCurrentUser();
            var relation = UserService.UserInMagazine(magId, user.UserId);

            if (!relation || !ModelState.IsValid)
            {
                return(RedirectToAction("Index", "Magazines"));
            }

            if (!ModelState.IsValid)
            {
                return(View(report));
            }
            var model = new Report
            {
                Comments   = report.Comments,
                Impact     = report.Impact,
                IsPaid     = report.IsPaid,
                IsPositive = report.IsPositive,
                MagazineId = magId,
                MediaId    = report.MediaId,
                ReportId   = report.ReportId,
                Title      = report.Title
            };

            if (ModelState.IsValid)
            {
                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.NewsId  = new SelectList(db.NewsesList.Where(x => x.Category.MagazineId == magId).Where(x => !x.IsDeleted), "NewsId", "Title");
            ViewBag.MediaId = new SelectList(db.MediasList.Where(x => !x.IsDeleted), "MediaId", "Name");
            return(View(report));
        }