public IHttpActionResult Post(Furnituring furnituring)
        {
            // Check for bad values, done by the data annotations in the model class.
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            // Try to save furnituring
            try
            {
                furnituringService.SaveFurnituring(furnituring);
            }
            catch (DataBaseEntryNotFoundException)
            {
                return NotFound();
            }
            catch (DuplicateNameException)
            {
                return Conflict();
            }
            catch (ApprovedException exception)
            {
                return BadRequest(exception.Message);
            }
            catch
            {
                return InternalServerError();
            }

            // Respond that the booking was created and redirect
            return Ok(furnituring); //CreatedAtRoute("DefaultApi", new { id = furnituring.FurnituringId }, furnituring);
        }
        public void SaveFurnituring(Furnituring Furnituring)
        {
            // Preparare validation return data
            ICollection<ValidationResult> validationResults;

            // Try to validate given data
            if (Furnituring.Validate(out validationResults))
            {
                // If a new Furnituring should be created
                if (Furnituring.FurnituringId == 0)
                {
                    FurnituringDAL.InsertFurnituring(Furnituring);
                }
                // Existing Furnituring should be updated
                else
                {
                    // Check that the Furnituring exists before update
                    if (FurnituringDAL.GetFurnituringById(Furnituring.FurnituringId) == null)
                    {
                        throw new DataBaseEntryNotFoundException();
                    }

                    // Update Furnituring
                    FurnituringDAL.UpdateFurnituring(Furnituring);
                }
            }
            // Validation failed
            else
            {
                // Create exception
                ApplicationException exception = new ApplicationException("Furnituring object contained invalid values.");

                // Add validation data to exception.
                exception.Data.Add("ValidationResults", validationResults);

                throw exception;
            }
        }
 // Methods
 public void FurnituringDelete(Furnituring Furnituring)
 {
     FurnituringDelete(Furnituring.FurnituringId);
 }
        public void UpdateFurnituring(Furnituring Furnituring)
        {
            // Create connection object
            using (this.CreateConnection())
            {
                try
                {
                    SqlCommand cmd;

                    // Connect to database
                    cmd = this.Setup("appSchema.usp_FurnituringUpdate", DALOptions.closedConnection);

                    // Add in parameters for Stored procedure
                    cmd.Parameters.Add("@FurnituringId", SqlDbType.SmallInt).Value = Furnituring.FurnituringId;
                    cmd.Parameters.Add("@Name", SqlDbType.VarChar, 50).Value = Furnituring.Name;

                    // Open DB connection
                    connection.Open();

                    // Execute insert to database
                    cmd.ExecuteNonQuery();
                }
                catch (Exception exception)
                {
                    if (exception.Message == "There is already a furnituring with the given name.")
                    {
                        throw new DuplicateNameException(exception.Message);
                    }
                    // Throw exception
                    throw new ApplicationException(DAL_ERROR_MSG);
                }
            }
        }