예제 #1
0
        public async Task <IHttpActionResult> Update(Guid id, FormDetailOptionViewModel item)
        {
            if (!authorizationService.IsAuthorized(item.Id, user.Email, AuthorizationService.AuthorizationType.IsUpdate, AuthorizationService.EndpointType.Form))
            {
                return(Content(HttpStatusCode.Forbidden, "You are not authorized to perform this action."));
            }
            var record = await repository.Update(id, item.ToEntity());

            var model = record.ToViewModel();

            return(Content(HttpStatusCode.OK, model));
        }
예제 #2
0
        public async Task <IHttpActionResult> Create(FormDetailOptionViewModel item)
        {
            FormDetailOptionViewModel model = null;

            try
            {
                if (!authorizationService.IsAuthorized(item.Id, user.Email, AuthorizationService.AuthorizationType.IsCreate, AuthorizationService.EndpointType.Form))
                {
                    return(Content(HttpStatusCode.Forbidden, "You are not authorized to perform this action."));
                }
                var record = await repository.Create(item.ToEntity());

                model = record.ToViewModel();
                return(Content(HttpStatusCode.OK, model));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(Content(HttpStatusCode.InternalServerError, ex));
            }
        }