Пример #1
0
        public static DistrictDetails GetModelView(District district)
        {
            if (district == null)
                return null;

            var districtDetails = new DistrictDetails(district);
            return districtDetails;
        }
Пример #2
0
        public static DistrictDelete GetModelView(District district)
        {
            if (district == null)
                return null;

            var districtDelete = new DistrictDelete(district);
            return districtDelete;
        }
Пример #3
0
        public static bool Update(DefaultContext db, ref District district)
        {
            District dbDistrict = GetDetail(db, district.DistrictId);
            if (dbDistrict == null)
                return false;

            dbDistrict.CopyFrom(district);
            db.SaveChanges();

            district = dbDistrict;
            return true;
        }
Пример #4
0
        public static DeleteResult Delete(DefaultContext db, int id, out District district)
        {
            district = GetDetail(db, id);
            if (district == null)
                return DeleteResult.AuthorizationFailed;

            try
            {
                db.Districts.Remove(district);
                db.SaveChanges();
                return DeleteResult.Ok;
            }
            catch (Exception e)
            {
                Logger.SetLog(e);
                return DeleteResult.DbFailed;
            }
        }
Пример #5
0
 public DistrictEdit(District district)
 {
     DistrictId = district.DistrictId;
     Title = district.Title;
 }
Пример #6
0
 public DistrictDetails(District district)
 {
     Title = district.Title;
 }
Пример #7
0
        public static DistrictIndex[] GetModelView(District[] districts)
        {
            if (districts == null)
                return null;

            DistrictIndex[] districtIndices = districts.Select(d => new DistrictIndex(d)).ToArray();
            return districtIndices;
        }
Пример #8
0
 public DistrictIndex(District district)
 {
     DistrictId = district.DistrictId;
     Title = district.Title;
 }
Пример #9
0
 public DistrictDelete(District district)
 {
     Title = district.Title;
 }
Пример #10
0
 public District GetModel()
 {
     var district = new District
                        {
                            DistrictId = DistrictId,
                            Title = Title
                        };
     return district;
 }
Пример #11
0
        public static DistrictEdit GetModelView(District district)
        {
            if (district == null)
                return null;

            var districtEdit = new DistrictEdit(district);
            return districtEdit;
        }
Пример #12
0
 public void CopyFrom(District district)
 {
     Title = district.Title;
 }
Пример #13
0
 private static void FixDistricts(ref DbSet<District> districtSet)
 {
     var district = new District
     {
         DistrictId = 1,
         Title = "Mladá Boleslav"
     };
     districtSet.AddOrUpdate(district);
 }
Пример #14
0
 private bool IsAccess(District district)
 {
     return district != null;
 }
Пример #15
0
 public static void Insert(DefaultContext db, District district)
 {
     db.Districts.Add(district);
     db.SaveChanges();
 }