예제 #1
0
    public async Task <ActionResult <AppAttachmentModel> > Create(
        [FromBody] AppAttachmentModel model
        )
    {
        try {
            await repository.SaveAsync(model);

            return(model);
        }
        catch (Exception ex) {
            logger.LogError(ex, $"Can not save {model.ToJson()} to app_attachments.");
            return(this.InternalServerError(ex));
        }
    }
예제 #2
0
    public async Task <ActionResult <AppAttachmentModel> > Update(
        [FromRoute] long id,
        [FromBody] AppAttachmentModel model
        )
    {
        try {
            var exists = await repository.ExistAsync(id);

            if (!exists)
            {
                return(NotFound());
            }
            model.Id = id.ToString();
            await repository.UpdateAsync(id, model);

            return(model);
        }
        catch (Exception ex) {
            logger.LogError(ex, $"Can not update app_attachments by {id} with {model.ToJson()}.");
            return(this.InternalServerError(ex));
        }
    }