public ActionResult Details(Guid guid) { YoumotoDbContext context = new YoumotoDbContext(); var news = NewsPersister.LoadSingle(context, guid); var viewModel = new NewsViewModel.Details(news); return(View(viewModel)); }
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(); }
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)); }
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)); }