public async Task EditHospitalByIdAsync(Guid id, Hospital hospital) { var existingHospital = await _context.Hospitals.FindAsync(id); existingHospital.Name = hospital.Name; existingHospital.MobileNumber = hospital.MobileNumber; existingHospital.Address = SqlAddress.FromDomain(hospital.Address); // _context.Update(SqlHospital.ToDomain(hospital)); await _context.SaveChangesAsync(); }
public async Task EditPatientByIdAsync(Guid id, Patient patient) { var existingPatient = await _context.Patients.FindAsync(id); existingPatient.Name = patient.Name; existingPatient.DateOfBirth = patient.DateOfBirth; existingPatient.MobileNumber = patient.MobileNumber; existingPatient.HospitalId = patient.HospitalId; existingPatient.Gender = (int)patient.Gender; existingPatient.Address = SqlAddress.FromDomain(patient.Address); // _context.Update(SqlPatient.ToDomain(patient)); await _context.SaveChangesAsync(); }
public override IDataStructure GetDatasetStructure(string datasetName) { string @namespace; this.SplitDatasetName(datasetName, out @namespace, out datasetName); if (!this._mapper.Mapping.ContainsKey(@namespace)) { return(null); } SqlAddress sqlAddress = new SqlAddress(this._mapper.Mapping[@namespace].Split('.')); using (SqlConnection conn = new SqlConnection(this._connStr)) { if (sqlAddress.Server != null && sqlAddress.Server != conn.DataSource) { return(null); } if (sqlAddress.Database != null && conn.Database != string.Empty && sqlAddress.Database != conn.Database) { return(null); } Server server = new Server(new ServerConnection(conn)); string dbName = sqlAddress.Database.In(string.Empty, null) ? conn.Database : sqlAddress.Database; string schema = sqlAddress.Schema.In(string.Empty, null) ? "dbo" : sqlAddress.Schema; string tableName = $"{sqlAddress.TablePrefix}{datasetName}"; if (server.Databases.Contains(dbName)) { IDataStructure structure = this._dsResolver(); Database database = server.Databases[dbName]; Table table = null; if (database.Tables.Contains(tableName, schema)) { table = database.Tables[tableName, schema]; } if (table == null) { return(null); } List <StructureComponent> identifiers = new List <StructureComponent>(); List <StructureComponent> measures = new List <StructureComponent>(); List <StructureComponent> viralAttributes = new List <StructureComponent>(); List <StructureComponent> nonViralAttributes = new List <StructureComponent>(); foreach (Column column in table.Columns) { StructureComponent comp = new StructureComponent(this.MapTypes(column.DataType.SqlDataType), column.Name); if (column.ExtendedProperties.Contains("vtl_component_role")) { switch (column.ExtendedProperties["vtl_component_role"].Value.ToString()) { case "identifier": comp.ComponentType = ComponentType.Identifier; identifiers.Add(comp); break; case "attribute": case "attribute.nonviral": comp.ComponentType = ComponentType.NonViralAttribute; nonViralAttributes.Add(comp); break; case "attribute.viral": comp.ComponentType = ComponentType.ViralAttribute; viralAttributes.Add(comp); break; case "measure": default: comp.ComponentType = ComponentType.Measure; measures.Add(comp); break; } } else { if (column.ExtendedProperties.Contains("vtl_time_type")) { switch (column.ExtendedProperties["vtl_time_type"].Value.ToString()) { case "time": comp.ValueDomain = new ValueDomain(BasicDataType.Time); break; case "date": comp.ValueDomain = new ValueDomain(BasicDataType.Date); break; case "time_period": comp.ValueDomain = new ValueDomain(BasicDataType.TimePeriod); break; case "duration": comp.ValueDomain = new ValueDomain(BasicDataType.Duration); break; default: break; } } if (column.InPrimaryKey) { comp.ComponentType = ComponentType.Identifier; identifiers.Add(comp); } else { comp.ComponentType = ComponentType.Measure; measures.Add(comp); } } } structure.Identifiers = identifiers; structure.Measures = measures; structure.ViralAttributes = viralAttributes; structure.NonViralAttributes = nonViralAttributes; return(structure); } return(null); } }