public async Task <StoredFolderModelBussines <int> > CreateAsync(StoredFolderModelBussines <int> model) { var mappedModel = AutoMapperConfig.Mapper.Map <StoredFolderModel <int> >(model); var savedModel = await this._context.StoredFolders.AddAsync(mappedModel); await this._context.SaveChangesAsync(); return(await this.GetByIdAsync(savedModel.Entity.Id)); }
public async Task <StoredFolderModelBussines <int> > UpdateAsync(int id, StoredFolderModelBussines <int> model) { var raw = await this.GetRawByIdAsync(id); raw.IsDeleted = model.IsDeleted; raw.Path = model.Path ?? raw.Path; raw.Size = model.Size; raw.Title = model.Title ?? raw.Title; raw.StoredFolderId = model?.StoredFolderId; raw.RootFolderId = (model.RootFolderId == null && raw.StoredFolderId == null)?raw.RootFolderId:model.RootFolderId; _context.StoredFolders.Update(raw); await _context.SaveChangesAsync(); return(await GetByIdAsync(id)); }