public IHttpActionResult Patch([FromODataUri] int key, Delta <EmployeeDTO> patch) { EmployeeDTO employeeDTO = null; try { if (IsUpdate(OperationResult)) { if (ValidateModelState(OperationResult)) { Employee employee = Application.UnitOfWork.GetRepository <Employee>().GetById(key); if (employee != null) { employeeDTO = new EmployeeDTO(employee); patch.Patch(employeeDTO); LibraryHelper.Clone <Employee>((Employee)employeeDTO.ToData(), employee, null); Application.UnitOfWork.Save(OperationResult); return(Updated(employeeDTO)); } } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Patch([FromODataUri] int key, Delta <MediaTypeDTO> patch) { MediaTypeDTO mediaTypeDTO = null; try { if (IsUpdate(OperationResult)) { if (ValidateModelState(OperationResult)) { MediaType mediaType = Application.UnitOfWork.GetRepository <MediaType>().GetById(key); if (mediaType != null) { mediaTypeDTO = new MediaTypeDTO(mediaType); patch.Patch(mediaTypeDTO); LibraryHelper.Clone <MediaType>((MediaType)mediaTypeDTO.ToData(), mediaType, null); Application.UnitOfWork.Save(OperationResult); return(Updated(mediaTypeDTO)); } } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Patch([FromODataUri] int key, Delta <InvoiceDTO> patch) { InvoiceDTO invoiceDTO = null; try { if (IsUpdate(OperationResult)) { if (ValidateModelState(OperationResult)) { Invoice invoice = Application.UnitOfWork.GetRepository <Invoice>().GetById(key); if (invoice != null) { invoiceDTO = new InvoiceDTO(invoice); patch.Patch(invoiceDTO); LibraryHelper.Clone <Invoice>((Invoice)invoiceDTO.ToData(), invoice, null); Application.UnitOfWork.Save(OperationResult); return(Updated(invoiceDTO)); } } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IQueryable <PlaylistTrackDTO> Get(ODataQueryOptions queryOptions) { IQueryable query = null; try { if (IsSearch(OperationResult)) { var settings = new ODataValidationSettings() { AllowedFunctions = AllowedFunctions.AllMathFunctions }; queryOptions.Validate(settings); query = queryOptions.ApplyTo(Application.QueryDTO); return(query as IQueryable <PlaylistTrackDTO>); } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Patch([FromODataUri] int key, Delta <PlaylistTrackDTO> patch) { PlaylistTrackDTO playlistTrackDTO = null; try { if (IsUpdate(OperationResult)) { if (ValidateModelState(OperationResult)) { PlaylistTrack playlistTrack = Application.UnitOfWork.GetRepository <PlaylistTrack>().GetById(key); if (playlistTrack != null) { playlistTrackDTO = new PlaylistTrackDTO(playlistTrack); patch.Patch(playlistTrackDTO); LibraryHelper.Clone <PlaylistTrack>((PlaylistTrack)playlistTrackDTO.ToData(), playlistTrack, null); Application.UnitOfWork.Save(OperationResult); return(Updated(playlistTrackDTO)); } } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Patch([FromODataUri] int key, Delta <ArtistDTO> patch) { ArtistDTO artistDTO = null; try { if (IsUpdate(OperationResult)) { if (ValidateModelState(OperationResult)) { Artist artist = Application.UnitOfWork.GetRepository <Artist>().GetById(key); if (artist != null) { artistDTO = new ArtistDTO(artist); patch.Patch(artistDTO); LibraryHelper.Clone <Artist>((Artist)artistDTO.ToData(), artist, null); Application.UnitOfWork.Save(OperationResult); return(Updated(artistDTO)); } } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Patch([FromODataUri] int key, Delta <CustomerDTO> patch) { CustomerDTO customerDTO = null; try { if (IsUpdate(OperationResult)) { if (ValidateModelState(OperationResult)) { Customer customer = Application.UnitOfWork.GetRepository <Customer>().GetById(key); if (customer != null) { customerDTO = new CustomerDTO(customer); patch.Patch(customerDTO); LibraryHelper.Clone <Customer>((Customer)customerDTO.ToData(), customer, null); Application.UnitOfWork.Save(OperationResult); return(Updated(customerDTO)); } } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Patch([FromODataUri] int key, Delta <GenreDTO> patch) { GenreDTO genreDTO = null; try { if (IsUpdate(OperationResult)) { if (ValidateModelState(OperationResult)) { Genre genre = Application.UnitOfWork.GetRepository <Genre>().GetById(key); if (genre != null) { genreDTO = new GenreDTO(genre); patch.Patch(genreDTO); LibraryHelper.Clone <Genre>((Genre)genreDTO.ToData(), genre, null); Application.UnitOfWork.Save(OperationResult); return(Updated(genreDTO)); } } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Post(PlaylistTrackDTO playlistTrack) { try { if (IsCreate(OperationResult)) { if (ValidateModelState(OperationResult)) { Application.Create(OperationResult, playlistTrack); return(Created(playlistTrack)); } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Put([FromODataUri] int key, PlaylistTrackDTO playlistTrack) { try { if (IsUpdate(OperationResult)) { if (ValidateModelState(OperationResult)) { Application.Update(OperationResult, playlistTrack); return(Updated(playlistTrack)); } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Post(EmployeeDTO employee) { try { if (IsCreate(OperationResult)) { if (ValidateModelState(OperationResult)) { Application.Create(OperationResult, employee); return(Created(employee)); } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Put([FromODataUri] int key, EmployeeDTO employee) { try { if (IsUpdate(OperationResult)) { if (ValidateModelState(OperationResult)) { Application.Update(OperationResult, employee); return(Updated(employee)); } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Post(CustomerDTO customer) { try { if (IsCreate(OperationResult)) { if (ValidateModelState(OperationResult)) { Application.Create(OperationResult, customer); return(Created(customer)); } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Put([FromODataUri] int key, CustomerDocumentDTO customerDocument) { try { if (IsUpdate(OperationResult)) { if (ValidateModelState(OperationResult)) { Application.Update(OperationResult, customerDocument); return(Updated(customerDocument)); } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Delete([FromODataUri] int key) { try { if (IsDelete(OperationResult)) { PlaylistTrack playlistTrack = Application.UnitOfWork.GetRepository <PlaylistTrack>().GetById(key); if (playlistTrack != null) { Application.Delete(OperationResult, new PlaylistTrackDTO(playlistTrack)); return(StatusCode(HttpStatusCode.NoContent)); } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Delete([FromODataUri] int key) { try { if (IsDelete(OperationResult)) { Employee employee = Application.UnitOfWork.GetRepository <Employee>().GetById(key); if (employee != null) { Application.Delete(OperationResult, new EmployeeDTO(employee)); return(StatusCode(HttpStatusCode.NoContent)); } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }
public IHttpActionResult Delete([FromODataUri] int key) { try { if (IsDelete(OperationResult)) { CustomerDocument customerDocument = Application.UnitOfWork.GetRepository <CustomerDocument>().GetById(key); if (customerDocument != null) { Application.Delete(OperationResult, new CustomerDocumentDTO(customerDocument)); return(StatusCode(HttpStatusCode.NoContent)); } } } catch (Exception exception) { OperationResult.ParseException(exception); } throw ODataHelper.OperationResultResponseException(Request, OperationResult); }