コード例 #1
0
        public Country DeleteCountry(int idToSearch)
        {
            Country found = null;

            using (PropertyHubContext context = new PropertyHubContext())
            {
                found = context.Find <Country>(idToSearch);
                context.Remove(found);
                context.SaveChanges();
            }
            return(found);
        }
コード例 #2
0
        public Province DeleteProvince(int idToSearch)
        {
            Province found = null;

            using (PropertyHubContext context = new PropertyHubContext())
            {
                found = context.Find <Province>(idToSearch);
                context.Remove(found);
                context.SaveChanges();
            }
            return(found);
        }
コード例 #3
0
        public Province UpdateProvince(int idToSearch, Province entity)
        {
            Province found = null;

            using (PropertyHubContext context = new PropertyHubContext())
            {
                found      = context.Find <Province>(idToSearch);
                found.Name = entity.Name;
                if (entity.Country?.Id > 0)
                {
                    found.Country = entity.Country;
                }
                context.SaveChanges();
            }
            return(found);
        }
コード例 #4
0
        public Country UpdateCountry(int idToSearch, Country entity)
        {
            Country found = null;

            using (PropertyHubContext context = new PropertyHubContext())
            {
                found = context.Find <Country>(idToSearch);
                if (entity.Code.HasValue && entity.Code != 0)
                {
                    found.Code = entity.Code;
                }
                if (!string.IsNullOrEmpty(entity.Name))
                {
                    found.Name = entity.Name;
                }
                context.SaveChanges();
            }
            return(entity);
        }