Exemplo n.º 1
0
    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));
    }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
    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());
    }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
0
        public async Task <IActionResult> GetApp(string appId)
        {
            var response = await AppDetailsDto.FromDomainObjectAsync(App, UserId, userResolver);

            return(Ok(response));
        }