public ContractorView(Contractor contractor, ContextManager Manager) { manager = Manager; this.LastName = contractor.LastName; this.FirstName = contractor.FirstName; this.MiddleName = contractor.MiddleName; this.Country = contractor.Country; this.Region = contractor.Region; this.District = contractor.District; this.City = contractor.City; this.Street = contractor.Street; this.Building = contractor.Building; this.Flat = contractor.Flat; this.ID = contractor.ID; this.Phone = contractor.Phone; this.MobilePhone = contractor.MobilePhone; this.EMail = contractor.EMail; this.Site = contractor.Site; this.Birthdate = contractor.Birthdate; this.Sex = contractor.Sex; this.Person = contractor.Person; ContractorsLogic cl = new ContractorsLogic(manager); contractorTypesObjectsList = new List <ContractorType>(); foreach (var a in cl.GetContractorTypesForContractor(this.ID)) { this.contractorTypesList = this.contractorTypesList + a.ContractorType.Name + "; "; this.contractorTypesObjectsList.Add(a.ContractorType); } }
public int Create(int ContractorID, CWCar Car) { int result = 1; Contractors.ContractorsLogic contractorsLogic = new Contractors.ContractorsLogic(manager); var carExists = from a in context.CWContractorCars where a.ContractorID == ContractorID & a.CWCar.Number == Car.Number & a.CWCar.ModelID == Car.ModelID & a.CWCar.BrandID == Car.BrandID select a; if (carExists.Count() == 0) { Contractor contractor = contractorsLogic.Get(ContractorID); if (contractor != null) { CWContractorCar cc = new CWContractorCar(); cc.ContractorID = ContractorID; Car.CWContractorCars.Add(cc); context.AddToCWContractorCars(cc); } } return(result); }