コード例 #1
0
        public ActionResult Details(Guid guid)
        {
            YoumotoDbContext context = new YoumotoDbContext();
            var news      = NewsPersister.LoadSingle(context, guid);
            var viewModel = new NewsViewModel.Details(news);

            return(View(viewModel));
        }
コード例 #2
0
        public void UpdateNews(Guid guid, String title, String text, String sourceLink)
        {
            YoumotoDbContext context = this.context ?? new YoumotoDbContext();
            var item = NewsPersister.LoadSingle(context, guid);

            item.Title           = title ?? String.Empty;
            item.Text            = text ?? String.Empty;
            item.SourceLink      = sourceLink ?? String.Empty;
            item.UpdateTimeStamp = DateTime.UtcNow;
            context.SaveChangesAsync();
        }
コード例 #3
0
        public NewsViewModel.Details AddPicture(Guid newsGuid, String pictureUrl)
        {
            YoumotoDbContext context = this.context ?? new YoumotoDbContext();

            var result = NewsPersister.LoadSingle(context, newsGuid);

            var newPicture = NewsPersister.CreatePicture(result, pictureUrl);

            context.NewsPictures.Add(newPicture);
            context.SaveChanges();

            return(new Models.NewsViewModel.Details(result));
        }
コード例 #4
0
        public NewsViewModel.Details AddVehicle(Guid newsGuid, Guid vehicleGuid)
        {
            YoumotoDbContext context = this.context ?? new YoumotoDbContext();

            var result  = NewsPersister.LoadSingle(context, newsGuid);
            var vehicle = VehiclePersister.LoadSingle(context, vehicleGuid);

            var newPicture = NewsPersister.CreateVehicle(result, vehicle);

            context.NewsVehicles.Add(newPicture);
            context.SaveChanges();

            return(new Models.NewsViewModel.Details(result));
        }