コード例 #1
0
 private void AddImageToAlbum(Album album, HttpPostedFileBase image)
 {
     album.ImageMimeType = image.ContentType;
     album.ImageData = new byte[image.ContentLength];
     image.InputStream.Read(album.ImageData, 0, image.ContentLength);
 }
コード例 #2
0
 private Album ApplyItemChanges(AlbumViewModel model)
 {
     Album result = GetAlbum(model.Id);
     if (result == null)
     {
         result=new Album();
     }
     result.Name = model.Name;
     result.Description = model.Description;
     result.Rate = model.Rate;
     result.AutorId = db.Autors.FirstOrDefault(a => a.Name == model.AutorName).AutorId;
     return result;
 }
コード例 #3
0
 private AlbumViewModel EditViewModelInitializer(Album album)
 {
     AlbumViewModel result = new AlbumViewModel
     {
         Description = album.Description,
         Id = album.AlbumId,
         list = new List<SelectListItem>(),
         Name = album.Name,
         AutorName = GetAutor(album.AutorId).Name,
         Rate = album.Rate
     };
     foreach (var item in GetAutorsList())
     {
         result.list.Add(new SelectListItem {Text = item.Name});
     }
     return result;
 }