示例#1
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Text,ComposerId")] Track track, HttpPostedFileBase thumbnail)
        {
            ViewBag.ComposerId = new SelectList(db.Composers, "Id", "Fullname", track.ComposerId);

            db.Entry(track).State = EntityState.Modified;
            if (thumbnail != null)
            {
                track.Thumbnail = Thumbnail.Create(thumbnail);
            }
            else
            {
                db.Entry(track).Property(x => x.Thumbnail).IsModified = false;
            }
            if (ModelState.IsValid)
            {
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView(track));
            }
            return(View(track));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Text,GenusId")] Instrument instrument, HttpPostedFileBase thumbnail)
        {
            db.Entry(instrument).State = EntityState.Modified;
            if (thumbnail != null)
            {
                instrument.Thumbnail = Thumbnail.Create(thumbnail);
            }
            else
            {
                db.Entry(instrument).Property(x => x.Thumbnail).IsModified = false;
            }
            if (ModelState.IsValid)
            {
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.GenusId = new SelectList(db.Genus, "Id", "Title");

            if (Request.IsAjaxRequest())
            {
                return(PartialView(instrument));
            }
            return(View(instrument));
        }
示例#3
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Title,Text")] Genus genus, HttpPostedFileBase thumbnail)
        {
            genus.Thumbnail = Thumbnail.Create(thumbnail);
            if (ModelState.IsValid)
            {
                genus.Id = Guid.NewGuid();
                db.Genus.Add(genus);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView(genus));
            }
            return(View(genus));
        }
示例#4
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Date,Address,Description")] Concert concert, HttpPostedFileBase thumbnail)
        {
            concert.Thumbnail = Thumbnail.Create(thumbnail);
            if (ModelState.IsValid)
            {
                concert.Id = Guid.NewGuid();
                db.Concerts.Add(concert);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView(concert));
            }
            return(View(concert));
        }
示例#5
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Title,Abstract,Text")] News news, HttpPostedFileBase thumbnail)
        {
            news.Thumbnail = Thumbnail.Create(thumbnail);
            news.Date      = DateTime.Now.ToLongDateString();
            if (ModelState.IsValid)
            {
                db.News.Add(news);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView(news));
            }
            return(View(news));
        }
示例#6
0
        public async Task <ActionResult> Create([Bind(Include = "Id,FirstName,LastName,BirthYear,Text")] Stringer stringer, HttpPostedFileBase thumbnail)
        {
            stringer.Thumbnail = Thumbnail.Create(thumbnail);
            if (ModelState.IsValid)
            {
                stringer.Id = Guid.NewGuid();
                db.Stringers.Add(stringer);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView(stringer));
            }
            return(View(stringer));
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Text,GenusId")] Instrument instrument, HttpPostedFileBase thumbnail)
        {
            instrument.Thumbnail = Thumbnail.Create(thumbnail);
            if (ModelState.IsValid)
            {
                instrument.Id = Guid.NewGuid();
                db.Instruments.Add(instrument);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.GenusId = new SelectList(db.Genus, "Id", "Title");
            if (Request.IsAjaxRequest())
            {
                return(PartialView(instrument));
            }
            return(View(instrument));
        }
示例#8
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Text,ComposerId")] Track track, HttpPostedFileBase thumbnail)
        {
            track.Thumbnail = Thumbnail.Create(thumbnail);
            if (ModelState.IsValid)
            {
                track.Id = Guid.NewGuid();
                db.Tracks.Add(track);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.ComposerId = new SelectList(db.Composers, "Id", "Fullname", track.ComposerId);
            if (Request.IsAjaxRequest())
            {
                return(PartialView(track));
            }
            return(View(track));
        }
示例#9
0
 public async Task <ActionResult> Edit([Bind(Include = "Id,FirstName,LastName,BirthYear,Text")] Stringer stringer, HttpPostedFileBase thumbnail)
 {
     db.Entry(stringer).State = EntityState.Modified;
     if (thumbnail != null)
     {
         stringer.Thumbnail = Thumbnail.Create(thumbnail);
     }
     else
     {
         db.Entry(stringer).Property(x => x.Thumbnail).IsModified = false;
     }
     if (ModelState.IsValid)
     {
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     if (Request.IsAjaxRequest())
     {
         return(PartialView(stringer));
     }
     return(View(stringer));
 }
示例#10
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Date,Address,Description")] Concert concert, HttpPostedFileBase thumbnail)
        {
            db.Entry(concert).State = EntityState.Modified;
            if (thumbnail != null)
            {
                concert.Thumbnail = Thumbnail.Create(thumbnail);
            }
            else
            {
                db.Entry(concert).Property(x => x.Thumbnail).IsModified = false;
            }
            if (ModelState.IsValid)
            {
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView(concert));
            }
            return(View(concert));
        }
示例#11
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Date,Title,Abstract,Text")] News news, HttpPostedFileBase thumbnail)
        {
            db.Entry(news).State = EntityState.Modified;
            if (thumbnail != null)
            {
                news.Thumbnail = Thumbnail.Create(thumbnail);
            }
            else
            {
                db.Entry(news).Property(x => x.Thumbnail).IsModified = false;
            }
            if (ModelState.IsValid)
            {
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView(news));
            }
            return(View(news));
        }