示例#1
0
        public static BusinessObjects.District GetDetails(int Id)
        {
            DistrictDA D = new DistrictDA();
            var InDb = D.context.Districts.SingleOrDefault(d => d.Id == Id);
            BusinessObjects.District district = new BusinessObjects.District
            {
                Id = InDb.Id,
                Name = InDb.Name
            };
            D.context.Dispose();

            return district;
        }
示例#2
0
        public static bool Delete(BusinessObjects.District districtBO)
        {
            DistrictDA D = new DistrictDA();
            var InDb = D.context.Districts.SingleOrDefault(d => d.Id == districtBO.Id);
            D.context.Districts.Remove(InDb);

            int affectedRows = D.context.SaveChanges();
            D.context.Dispose();

            if (affectedRows > 0)
                return true;
            else
                return false;
        }
示例#3
0
        public static bool Add(BusinessObjects.District districtBO)
        {
            DistrictDA D = new DistrictDA();
            var district = new District
            {
                Name = districtBO.Name
            };
            D.context.Districts.Add(district);
            int affectedRows = D.context.SaveChanges();
            D.context.Dispose();

            if (affectedRows > 0)
                return true;
            else
                return false;
        }
示例#4
0
        public static List<BusinessObjects.District> GetAll()
        {
            DistrictDA D = new DistrictDA();
            List<BusinessObjects.District> list = new List<BusinessObjects.District>();

            var InDbList = D.context.Districts.ToList();

            foreach(var single in InDbList)
            {
                BusinessObjects.District district = new BusinessObjects.District
                {
                    Id = single.Id,
                    Name = single.Name
                };
                list.Add(district);
            }
            return list;
        }