Esempio n. 1
0
        public ActionResult Edit([Bind(Include = "Id,Room,Place,IsTaken")] BookLocation bookLocation, string Readers)
        {
            if (!User.IsInRole("Admin"))
            {
                return(HttpNotFound());
            }
            if (ModelState.IsValid)
            {
                bookLocation = db.BookLocations.Find(bookLocation.Id);
                var Reader = db.Readers.ToList().First(e => e.ToString() == Readers);
                db.Entry(bookLocation).State = EntityState.Modified;

                if (!db.BookLocations.Find(bookLocation.Id).IsTaken&& bookLocation.IsTaken)
                {
                    db.Stats.Add(new Stats {
                        DateTaken = DateTime.Now, Publication = bookLocation.Publication
                    });
                }
                db.BookLocations.Find(bookLocation.Id).Reader = Reader;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Publications = new SelectList(db.Publications, bookLocation.Publication);
            ViewBag.Readers      = new SelectList(db.Readers, bookLocation.Reader);

            return(View(bookLocation));
        }
        public ActionResult Edit([Bind(Include = "Id,First,Last,Patronimic,toEnumWT")] Author author)
        {
            if (!User.IsInRole("Admin"))
            {
                return(HttpNotFound());
            }

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

            return(View(author));
        }
Esempio n. 3
0
        public ActionResult Edit([Bind(Include = "Id,Name")] Discipline discipline)
        {
            if (!User.IsInRole("Admin"))
            {
                return(HttpNotFound());
            }

            {
                if (ModelState.IsValid)
                {
                    db.Entry(discipline).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            return(View(discipline));
        }
Esempio n. 4
0
        public ActionResult Edit([Bind(Include = "Id,DateTaken")] Stats stats, string Publications)
        {
            if (!User.IsInRole("Admin"))
            {
                return(HttpNotFound());
            }

            {
                if (ModelState.IsValid)
                {
                    db.Entry(stats).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                ViewBag.Publications = new SelectList(db.Publications, "Id", "Name", stats.Publication);
            }
            return(View(stats));
        }
        public ActionResult Edit([Bind(Include = "Id,First,Last,Patronimic,toEnumAL,Group")] Reader reader)
        {
            if (!User.IsInRole("Admin"))
            {
                return(HttpNotFound());
            }


            if (ModelState.IsValid)
            {
                if (reader.Group == null)
                {
                    reader.Group = string.Empty;
                }
                db.Entry(reader).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(reader));
        }
        public ActionResult Edit([Bind(Include = "Id,Name,DatePublished,toEnumPT,Publisher,InternetLocation")] Publication publication, string[] Authors, string[] Courses, string[] Disciplines)
        {
            if (!User.IsInRole("Admin"))
            {
                return(HttpNotFound());
            }
            ViewBag.db = db;

            var publication2 = db.Publications.Find(publication.Id);

            publication2.Id               = publication.Id;
            publication2.Publisher        = publication2.Publisher;
            publication2.Name             = publication.Name;
            publication2.toEnumPT         = publication.toEnumPT;
            publication2.DatePublished    = publication.DatePublished;
            publication2.InternetLocation = publication.InternetLocation;
            publication = publication2;

            if (Authors != null)
            {
                publication.Authors.Clear();
                foreach (var author in db.Authors)
                {
                    if (Authors.Any(e => e == author.ToString()))
                    {
                        publication.Authors.Add(author);
                    }
                }
            }

            if (Courses != null)
            {
                publication.Courses.Clear();
                foreach (Courses course in db.Courses)
                {
                    if (Courses.Any(e => e == course.ToString()))
                    {
                        publication.Courses.Add(course);
                    }
                }
            }

            if (Disciplines != null)
            {
                publication.Disciplines.Clear();
                foreach (var discipline in db.Disciplines)
                {
                    if (Disciplines.Any(e => e == discipline.ToString()))
                    {
                        publication.Disciplines.Add(discipline);
                    }
                }
            }

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

            return(View(publication));
        }