public async Task <StoredFileModelBussines <int> > UpdateAsync(int id, StoredFileModelBussines <int> model) { var raw = await this.GetRawByIdAsync(id); raw.Title = model.Title ?? raw.Title; raw.ThumbnailPath = model.ThumbnailPath ?? raw.ThumbnailPath; raw.RootFolderId = model.RootFolderId ?? raw.RootFolderId; raw.StoredFolderId = model.StoredFolderId ?? raw.StoredFolderId; raw.IsDeleted = model.IsDeleted; if (default(Int32) != model.SizeInKbs) { raw.SizeInKbs = model.SizeInKbs; } var updated = this._context.StoredFiles.Update(raw); await this._context.SaveChangesAsync(); return(AutoMapperConfig.Mapper.Map <StoredFileModelBussines <int> >(updated.Entity)); }
public async Task <StoredFileModelBussines <int> > CreateAsync(StoredFileModelBussines <int> model) { var added = await this._context.StoredFiles.AddAsync( AutoMapperConfig.Mapper.Map <StoredFileModel <int> >(model) ); await this._context.SaveChangesAsync(); return(await this.GetByIdAsync(added.Entity.Id)); }