public ActionResult New() { // var contractor = _context.Contractors.Include(c => c.CooperationType) // .Include(c => c.ContractorBranch) // .Include(c => c.Province).SingleOrDefault(c => c.Id == id); //var cooperationTypes = _context.CooperationTypes.ToList(); //var contractorBranches = _context.ContractorBranches.ToList(); //var provinces = _context.Provinces.ToList(); //var contractorEmployees = _context.ContractorEmployees.Include(e => e.EmployeeSignificance).Where(c => c.ContractorId == id).ToList(); //var viewModel = new NewContractorViewModel //{ // Contractor = contractor, // CooperationTypes = cooperationTypes, // ContractorBranches = contractorBranches, // Provinces = provinces, // ContractorEmployees = contractorEmployees //}; var provinces = _context.Provinces.ToList(); var contractorBranches = _context.ContractorBranches.ToList(); var cooperationTypes = _context.CooperationTypes.ToList(); var viewModel = new NewContractorViewModel { ContractorBranches = contractorBranches, Provinces = provinces, CooperationTypes = cooperationTypes, Contractor = new Contractor() }; return(View(viewModel)); }
public ActionResult Edit(int id) { //// id = 1; //// var contractor = _context.Contractors.SingleOrDefault(c => c.Id == id); if (contractor == null) { return(HttpNotFound()); } var viewModel = new NewContractorViewModel { Contractor = contractor, CooperationTypes = _context.CooperationTypes.ToList() }; return(View("New", viewModel)); }
public ActionResult Details(int?id) { //id = (id == null) ? id = 1 : id = id; var contractor = _context.Contractors.Include(c => c.CooperationType) .Include(c => c.ContractorBranch) .Include(c => c.Province).SingleOrDefault(c => c.Id == id); var cooperationTypes = _context.CooperationTypes.ToList(); var contractorBranches = _context.ContractorBranches.ToList(); var provinces = _context.Provinces.ToList(); var contractorEmployees = _context.ContractorEmployees.Include(e => e.EmployeeSignificance).Where(c => c.ContractorId == id).ToList(); var notes = _context.Notes.Include(n => n.ContractorEmployee).Where(n => n.ContractorId == id).ToList(); var tasks = _context.UserTasks.Include(t => t.ContractorEmployee) .Include(t => t.UserTaskType).Where(t => t.ContractorId == id).ToList(); var offers = _context.ContractorOffer.Include(o => o.ContractorOfferType) .Include(o => o.ContractorEmployee).Where(o => o.ContractorId == id).ToList(); var viewModel = new NewContractorViewModel { Contractor = contractor, CooperationTypes = cooperationTypes, ContractorBranches = contractorBranches, Provinces = provinces, ContractorEmployees = contractorEmployees, Notes = notes, Tasks = tasks, Offers = offers }; return(View("Details", viewModel)); }