UpdateAsync() 공개 메소드

public UpdateAsync ( object>.Dictionary item, object primaryKeyValue, List customFields ) : System.Threading.Tasks.Task
item object>.Dictionary
primaryKeyValue object
customFields List
리턴 System.Threading.Tasks.Task
예제 #1
0
        public async Task<object> EditAsync(string schemaName, string tableName, string primaryKey, [FromBody] JArray form)
        {
            var item = form[0].ToObject<Dictionary<string, object>>();
            var customFields = form[1].ToObject<List<CustomField>>(JsonHelper.GetJsonSerializer());

            if(item == null)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.MethodNotAllowed));
            }

            try
            {
                var repository = new FormRepository(schemaName, tableName, this.AppUser.Tenant, this.AppUser.LoginId, this.AppUser.UserId);
                await repository.UpdateAsync(item, primaryKey, customFields).ConfigureAwait(false);
                return primaryKey;
            }
            catch(UnauthorizedException)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden));
            }
            catch(DataAccessException ex)
            {
                throw new HttpResponseException
                    (
                    new HttpResponseMessage
                    {
                        Content = new StringContent(ex.Message),
                        StatusCode = HttpStatusCode.InternalServerError
                    });
            }
#if !DEBUG
            catch
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
#endif
        }