public void CreateOrUpdateBuilding(BuildingPrimitive buildingPrimitive)
        {
            try
              {
            using (SmartWorkingEntities context = new SmartWorkingEntities())
            {
              Building building = buildingPrimitive.GetEntity();
              Building existingObject = context.Buildings.Where(x => x.Id == building.Id).FirstOrDefault();

              //no record of this item in the DB, item being passed in has a PK
              if (existingObject == null && building.Id > 0)
              {
            throw new FaultException<ExceptionDetail>(new ExceptionDetail(new Exception("Błąd zapisu do bazy")),
                                                        "Obiekt nie istniał w bazie, a jego Id jest większe od 0.");
              }
              //Item has no PK value, must be new
              else if (building.Id <= 0)
              {
            context.Buildings.AddObject(building);
              }
              //Item was retrieved, and the item passed has a valid ID, do an update
              else
              {
            context.Buildings.ApplyCurrentValues(building);
              }

              context.SaveChanges();
            }
              }
              catch (Exception e)
              {
            throw new FaultException<ExceptionDetail>(new ExceptionDetail(e), e.Message);
              }
        }