public static DistrictDetails GetModelView(District district) { if (district == null) return null; var districtDetails = new DistrictDetails(district); return districtDetails; }
public static DistrictDelete GetModelView(District district) { if (district == null) return null; var districtDelete = new DistrictDelete(district); return districtDelete; }
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; }
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; } }
public DistrictEdit(District district) { DistrictId = district.DistrictId; Title = district.Title; }
public DistrictDetails(District district) { Title = district.Title; }
public static DistrictIndex[] GetModelView(District[] districts) { if (districts == null) return null; DistrictIndex[] districtIndices = districts.Select(d => new DistrictIndex(d)).ToArray(); return districtIndices; }
public DistrictIndex(District district) { DistrictId = district.DistrictId; Title = district.Title; }
public DistrictDelete(District district) { Title = district.Title; }
public District GetModel() { var district = new District { DistrictId = DistrictId, Title = Title }; return district; }
public static DistrictEdit GetModelView(District district) { if (district == null) return null; var districtEdit = new DistrictEdit(district); return districtEdit; }
public void CopyFrom(District district) { Title = district.Title; }
private static void FixDistricts(ref DbSet<District> districtSet) { var district = new District { DistrictId = 1, Title = "Mladá Boleslav" }; districtSet.AddOrUpdate(district); }
private bool IsAccess(District district) { return district != null; }
public static void Insert(DefaultContext db, District district) { db.Districts.Add(district); db.SaveChanges(); }