Example #1
0
        // GET: Movies/Details/5
        public ActionResult Details(int id)
        {
            FilmDetail filmDetail = ServiceFilm.GetDetails(id);

            filmDetail.AllowEdit = Services.ServiceFilm.AllowToUpdate(id, CurrentUserName());
            return(View(filmDetail));
        }
Example #2
0
        public ActionResult Create(FilmNew filmNew, HttpPostedFileBase file)
        {
            if (string.IsNullOrEmpty(CurrentUserName()))
            {
                ModelState.AddModelError(string.Empty, "Для этой операции требуется авторизация");
            }

            if (ModelState.IsValid)
            {
                string pic = null;

                if (file != null)
                {
                    pic = System.IO.Path.GetFileName(file.FileName);
                    pic = string.Concat(Guid.NewGuid(), pic);
                    string path = System.IO.Path.Combine(
                        Server.MapPath("~/Images/FilmsImg"), pic);
                    // file is uploaded
                    file.SaveAs(path);
                }

                filmNew.Created = CurrentUserName();
                filmNew.Poster  = pic;
                ServiceFilm.Create(filmNew);
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(filmNew));
            }
        }
Example #3
0
        // GET: Movies
        public ActionResult Index(int?page)
        {
            var films     = ServiceFilm.Get();
            int pageSize  = 5;
            int pageIndex = 1;

            pageIndex = page != null?Convert.ToInt32(page) : 1;

            return(View(films.OrderBy(p => p.ID).ToPagedList(pageIndex, pageSize)));
        }
Example #4
0
        // GET: Movies/Edit/5
        public ActionResult Edit(int id)
        {
            FilmDetail filmDetail = ServiceFilm.GetDetails(id);

            return(View(filmDetail));
        }