public async Task <IActionResult> CreateApp(AppDetailsDto dto) { var app = CopyAppDetailsDtoToEntity(dto, new App()); context.Apps.Add(app); await context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetAppDetails), app.Id, app)); }
public async Task <IActionResult> PostContributor(string appId, [FromBody] AddContributorDto request) { var update = request.ToUpdate(UserId); var app = await appStore.UpsertAsync(appId, update, HttpContext.RequestAborted); var response = await AppDetailsDto.FromDomainObjectAsync(app, UserId, userResolver); return(Ok(response)); }
public async Task <IActionResult> DeleteContributor(string appId, string contributorId) { var update = new RemoveContributor { ContributorId = contributorId, UserId = UserId }; var app = await appStore.UpsertAsync(appId, update, HttpContext.RequestAborted); var response = await AppDetailsDto.FromDomainObjectAsync(app, UserId, userResolver); return(Ok(response)); }
public async Task <IActionResult> UpdateApp(AppDetailsDto dto) { var app = await context.Apps.Where(a => a.Id == dto.Id).SingleOrDefaultAsync(); if (app == null) { return(BadRequest()); } CopyAppDetailsDtoToEntity(dto, app); await context.SaveChangesAsync(); return(Ok()); }
private App CopyAppDetailsDtoToEntity(AppDetailsDto dto, App entity) { entity.Name = dto.Name; entity.ShortDescription = dto.ShortDescription; entity.Description = dto.Description; entity.ImagePath = dto.ImagePath; entity.Level = dto.Level; entity.Urls = dto.Urls; entity.Category = dto.Category; entity.AppLanguages = dto.Languages.Select(l => new AppLanguage() { Language = l }).ToList(); return(entity); }
public async Task <IActionResult> GetApp(string appId) { var response = await AppDetailsDto.FromDomainObjectAsync(App, UserId, userResolver); return(Ok(response)); }