public ServiceResult<IPropertyTag> UpdatePropertyTag(int id, string name)
        {
            ServiceResult<IPropertyTag> retVal = new ServiceResult<IPropertyTag>();
            FVCP.Persistence.EF.PropertyTag dbItem = null;
            using (var db = new PropertyEntities())
            {
                dbItem = db.PropertyTags
                    .FirstOrDefault(x => x.Id == id);

                if (dbItem != null)
                {
                    dbItem.Name = name;
                    db.SaveChanges();

                    PropertyTagFactory myFact = new PropertyTagFactory();
                    retVal.Data = myFact.Create(GetPropertyTagById(id).Data);
                    retVal.Success = true;
                }
                else
                {   // Item doesn't exist.
                    retVal.Success = false;
                    retVal.ErrorID = "404";
                    retVal.Message = string.Format("Tag id '{0}' was not found.  Unable to update property tag '{1}'.",
                        id, name);
                }
            }

            return retVal;
        }
        public ServiceResult<IPropertyTag> AddPropertyTag(string pin, string name)
        {
            ServiceResult<IPropertyTag> retVal = new ServiceResult<IPropertyTag>();
            FVCP.Persistence.EF.PropertyTag dbItem = null;
            using (var db = new PropertyEntities())
            {
                dbItem = db.PropertyTags
                    .FirstOrDefault(x => x.Pin == pin && x.Name == name);

                if (dbItem == null)
                {   // Go ahead and add the item, it isn't a duplicate.
                    dbItem = new EF.PropertyTag()
                    {
                        Name = name,
                        Pin = pin
                    };

                    db.PropertyTags.Add(dbItem);
                    db.SaveChanges();  // ID value should populate.

                    PropertyTagDTO dto = PropertyTagRepository.MapFieldValues(dbItem);
                    PropertyTagFactory myFact = new PropertyTagFactory();
                    retVal.Data = myFact.Create(dto);
                    retVal.Success = true;
                }
                else
                {
                    retVal.Success = false;
                    retVal.ErrorID = "422";
                    retVal.Message = string.Format("Unprocessable Entity - Tag '{0}' already exists for PIN '{1}'", name, pin);
                }
            }

            return retVal;
        }
        public IPropertyTag GetPropertyTagById(int id)
        {
            FVCP.Persistence.EF.PropertyTag dbItem = null;
            using (var db = new PropertyEntities())
            {
                dbItem = db.PropertyTags
                    .FirstOrDefault(x => x.Id == id);
            }

            PropertyTagDTO dto = PropertyTagRepository.MapFieldValues(dbItem);
            PropertyTagFactory myFact = new PropertyTagFactory();
            IPropertyTag retVal = myFact.Create(dto);

            return retVal;
        }