public ActionResult SelectSample(int id = 0) { var model = new SelectedSampleViewModel { SampleId = id }; return(View(model)); }
public ActionResult SelectSample(SelectedSampleViewModel model) { if (ModelState.IsValid) { int employeeId = _dataManager.Employees.GetIdByProperties(model.EmployeeFirstName, model.EmployeeLastName, model.EmployeeMiddleName, model.EmployeePost, "отбор проб"); if (employeeId == 0) { _dataManager.Employees.CreateEmployee(model.EmployeeFirstName, model.EmployeeLastName, model.EmployeeMiddleName, model.EmployeePost, "отбор проб", null, null); employeeId = _dataManager.Employees.GetIdByProperties(model.EmployeeFirstName, model.EmployeeLastName, model.EmployeeMiddleName, model.EmployeePost, "отбор проб"); } int technicalRegulationId = _dataManager.TechnicalRegulations.GetIdByProperties(model.TrDesignation, model.TrName); if (technicalRegulationId == 0) { _dataManager.TechnicalRegulations.CreateTechnicalRegulation(model.TrDesignation, model.TrName, null); technicalRegulationId = _dataManager.TechnicalRegulations.GetIdByProperties(model.TrDesignation, model.TrName); } _dataManager.SelectedSamples.CreateSelectedSample(model.SampleId, model.Manufacturer, model.SamplingPlace, model.NumberOfSelectedSample, model.Units, DateTime.Now, technicalRegulationId, employeeId); return(RedirectToAction("SelectedSamples")); } return(View(model)); }