public IActionResult CreateMaterial([FromBody] Material materialData)
        {
            // build server data
            var materialType = new
                               Server.Models.MaterialType {
                TypeId = materialData.Type.TypeId, Type = materialData.Type.Type
            };

            var materialSubjects = materialData.MaterialSubjects
                                   .Select(subject => new Server.Models.MaterialSubject
            {
                SubjectId = subject.SubjectId, SubjectName = subject.SubjectName
            })
                                   .ToList();

            var authors = materialData.Authors
                          .Select(author => new Server.Models.Author
            {
                AuthorId = author.AuthorId, FirstName = author.FirstName, LastName = author.LastName
            })
                          .ToList();

            // create & insert
            try
            {
                var material = _controller.Create(
                    materialData.Isbn,
                    materialData.Title,
                    materialData.Language,
                    materialData.Lendable,
                    materialData.Description,
                    materialType,
                    materialSubjects,
                    authors
                    );

                _controller.Insert(material);
                return(new JsonResult(BuildMaterial(material)));
            }
            catch (ArgumentException e)
            {
                return(BadRequest(e.Message));
            }
        }
        public IActionResult UpdateMaterial(int id, [FromBody] Material newMaterial)
        {
            var material = _controller.FindByID(id);

            if (material == null)
            {
                return(new NotFoundResult());
            }


            // build server data
            var materialType = new Server.Models.MaterialType
            {
                TypeId = newMaterial.Type.TypeId, Type = newMaterial.Type.Type
            };

            var materialSubjects = newMaterial.MaterialSubjects
                                   .Select(subject => new Server.Models.MaterialSubjects
            {
                MaterialSubject = new Server.Models.MaterialSubject
                {
                    SubjectName = subject.SubjectName, SubjectId = subject.SubjectId
                },
                Material = material
            })
                                   .ToList();

            var materialAuthors = newMaterial.Authors
                                  .Select(author => new Server.Models.MaterialAuthor
            {
                Material = material,
                Author   = new Server.Models.Author
                {
                    AuthorId = author.AuthorId, FirstName = author.FirstName, LastName = author.LastName
                }
            })
                                  .ToList();

            var newServerMaterial = new Server.Models.Material
            {
                Isbn             = newMaterial.Isbn,
                Title            = newMaterial.Title,
                Language         = newMaterial.Language,
                Description      = newMaterial.Description,
                Lendable         = newMaterial.Lendable,
                Type             = materialType,
                MaterialAuthors  = materialAuthors,
                MaterialSubjects = materialSubjects,
            };

            try
            {
                var changedRows = _controller.Update(id, newServerMaterial);
                // TODO: Add if statement that checks for the right amount of changedRows
            }
            catch (ArgumentException e)
            {
                return(BadRequest(e.Message));
            }

            material = _controller.FindByID(id);
            return(new JsonResult(BuildMaterial(material)));
        }