public bool CreateShow(TimeCreate model)
        {
            var entity =
                new AllShows()
            {
                OwnerId           = _userId,
                Title             = model.Title,
                Watchedbefore     = model.Watchedbefore,
                SeasonNumber      = model.SeasonNumber,
                EpisodesPerSeason = model.EpisodesPerSeason,
                EpisodeLength     = model.EpisodeLength,
                WorthIt           = model.WorthIt,
                TotalTime         = TotalTime(model.EpisodesPerSeason, model.EpisodeLength, model.SeasonNumber),

                CreatedUtc = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                //if()



                ctx.Shows.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Example #2
0
        public string ToLine()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(Id);
            stringBuilder.Append(spliter);
            stringBuilder.Append(Origin);
            stringBuilder.Append(spliter);
            stringBuilder.Append(Translate);
            stringBuilder.Append(spliter);
            stringBuilder.Append(CountShow.ToString());
            stringBuilder.Append(spliter);
            stringBuilder.Append(TimeShow.ToString(formatInWord));
            stringBuilder.Append(spliter);
            stringBuilder.Append(TimeCreate.ToString(formatInWord));
            stringBuilder.Append(spliter);
            stringBuilder.Append(Level);
            return(stringBuilder.ToString());
        }
Example #3
0
        public ActionResult Create(TimeCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateShowService();

            if (service.CreateShow(model))
            {
                TempData["SaveResult"] = "Your Show was created.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Show could not be created.");

            return(View(model));
        }