public async Task <IActionResult> PostCustomerCustomerDemo([FromBody] CustomerCustomerDemo customerCustomerDemo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.CustomerCustomerDemo.Add(customerCustomerDemo); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (CustomerCustomerDemoExists(customerCustomerDemo.CustomerId)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetCustomerCustomerDemo", new { id = customerCustomerDemo.CustomerId }, customerCustomerDemo)); }
public static CustomerCustomerDemoEntity FromDto(this CustomerCustomerDemo dto) { OnBeforeDtoToEntity(dto); var entity = new CustomerCustomerDemoEntity(); // Map entity properties entity.CustomerId = dto.CustomerId; entity.CustomerTypeId = dto.CustomerTypeId; // Map entity associations // n:1 Customer association if (dto.Customer != null) { entity.Customer = dto.Customer.FromDto(); } // n:1 CustomerDemographic association if (dto.CustomerDemographic != null) { entity.CustomerDemographic = dto.CustomerDemographic.FromDto(); } OnAfterDtoToEntity(dto, entity); return(entity); }
public List <CustomerCustomerDemo> getAllCustomerCustomerDemo() { List <CustomerCustomerDemo> customerCustomerDemoList = new List <CustomerCustomerDemo>(); Connection conn = new Connection(); SqlConnection connection = conn.SqlConnection; using (SqlCommand command = new SqlCommand("select * from CustomerCustomerDemo", connection)) { try { connection.Open(); SqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { CustomerCustomerDemo customerCustomerDemo = new CustomerCustomerDemo(dataReader.GetString(0), dataReader.GetString(1)); customerCustomerDemoList.Add(customerCustomerDemo); } dataReader.Close(); } catch (Exception exc) { logger.logError(DateTime.Now, "Error while trying to get all CustomerCustomerDemo."); MessageBox.Show(exc.Message); } logger.logInfo(DateTime.Now, "GetAllCustomerCustomerDemo method has sucessfully invoked."); return(customerCustomerDemoList); } }
public int addCustomerCustomerDemo(CustomerCustomerDemo customerCustomerDemo) { Connection conn = new Connection(); SqlConnection connection = conn.SqlConnection; SqlCommand insertCommand = new SqlCommand(); insertCommand.Connection = connection; insertCommand.CommandType = CommandType.StoredProcedure; insertCommand.CommandText = "AddCustomerCustomerDemo"; insertCommand.Parameters.Add("@CustomerID", SqlDbType.NChar); insertCommand.Parameters.Add("@CustomerTypeID", SqlDbType.NChar); insertCommand.Parameters["@CustomerID"].Value = customerCustomerDemo.CustomerID; insertCommand.Parameters["@CustomerTypeID"].Value = customerCustomerDemo.CustomerTypeID; try { connection.Open(); insertCommand.ExecuteScalar(); logger.logInfo(DateTime.Now, "AddCustomerCustomerDemo method has sucessfully invoked."); return(0); } catch (Exception ex) { logger.logError(DateTime.Now, "Error while trying to add new CustomerCustomerDemo."); MessageBox.Show(ex.Message); return(-1); } finally { connection.Close(); } }
public async Task <IActionResult> Edit(string id, [Bind("CustomerId,CustomerTypeId")] CustomerCustomerDemo customerCustomerDemo) { if (id != customerCustomerDemo.CustomerId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customerCustomerDemo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerCustomerDemoExists(customerCustomerDemo.CustomerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "CustomerId", customerCustomerDemo.CustomerId); ViewData["CustomerTypeId"] = new SelectList(_context.CustomerDemographics, "CustomerTypeId", "CustomerTypeId", customerCustomerDemo.CustomerTypeId); return(View(customerCustomerDemo)); }
private void CopyCustomerCustomerDemo(IOdb odb) { //Processing CustomerCustomerDemo LogMessage("Reading CustomerCustomerDemo...", false); var adapter1 = new CustomerCustomerDemoTableAdapter(); var table1 = adapter1.GetData(); LogMessage("processing " + table1.Count.ToString() + " rows", true); foreach (var row in table1) { LogMessage("CustomerCustomerDemo: " + row.CustomerID + "/" + row.CustomerTypeID + " ...", false); var ccd = new CustomerCustomerDemo(); LogMessage("linking members...", false); ccd.CustomerID = NDbUtil.GetByStringID <Customer>(odb, Customer.PK, row.CustomerID); ccd.CustomerTypeID = NDbUtil.GetByStringID <CustomerDemographics>(odb, CustomerDemographics.PK, row.CustomerTypeID); odb.Store(ccd); LogMessage("saved (" + ccd.CustomerID.CustomerID + "/" + ccd.CustomerTypeID.CustomerTypeID + ")", true); } odb.Commit(); long objectCount = NDbUtil.GetAllInstances <CustomerCustomerDemo>(odb).Count; if (table1.Count == objectCount) { LogMessage(table1.Count + " objects saved", true); } else { LogMessage("Error: " + table1.Count + " rows retrieved but " + objectCount + " objects were saved", true); } LogMessage("Done with CustomerCustomerDemo" + Environment.NewLine, true); }
private CustomerCustomerDemo MapData(SqlDataReader reader) { CustomerCustomerDemo ccd = new CustomerCustomerDemo(); ccd.CustomerID = reader["CustomerID"].ToString(); ccd.CustomerTypeID = reader["CustomerTypeID"].ToString(); return(ccd); }
///<summary> /// Update the Typed CustomerCustomerDemo Entity with modified mock values. ///</summary> public static void UpdateMockInstance(TransactionManager tm, CustomerCustomerDemo mock) { CustomerCustomerDemoTest.UpdateMockInstance_Generated(tm, mock); // make any alterations necessary // (i.e. for DB check constraints, special test cases, etc.) SetSpecialTestData(mock); }
protected async void GridDeleteButtonClick(UIMouseEventArgs args, CustomerCustomerDemo data) { var northwindDeleteCustomerCustomerDemoResult = await Northwind.DeleteCustomerCustomerDemo($"{data.CustomerID}", $"{data.CustomerTypeID}"); if (northwindDeleteCustomerCustomerDemoResult.IsSuccessStatusCode) { grid0.Reload(); } }
public CustomerCustomerDemoProxyStub CustomerCustomerDemo_GetByPrimaryKey(System.String customerID, System.String customerTypeID) { CustomerCustomerDemo obj = new CustomerCustomerDemo(); if (obj.LoadByPrimaryKey(customerID, customerTypeID)) { return(obj); } return(null); }
protected async void Load() { var northwindGetCustomersResult = await Northwind.GetCustomers(); getCustomersResult = northwindGetCustomersResult; var northwindGetCustomerDemographicsResult = await Northwind.GetCustomerDemographics(); getCustomerDemographicsResult = northwindGetCustomerDemographicsResult; customercustomerdemo = new CustomerCustomerDemo(); }
///<summary> /// Update the Typed CustomerCustomerDemo Entity with modified mock values. ///</summary> public static void UpdateMockInstance_Generated(TransactionManager tm, CustomerCustomerDemo mock) { //OneToOneRelationship CustomerDemographics mockCustomerDemographicsByCustomerTypeId = CustomerDemographicsTest.CreateMockInstance(tm); DataRepository.CustomerDemographicsProvider.Insert(tm, mockCustomerDemographicsByCustomerTypeId); mock.CustomerTypeId = mockCustomerDemographicsByCustomerTypeId.CustomerTypeId; //OneToOneRelationship Customers mockCustomersByCustomerId = CustomersTest.CreateMockInstance(tm); DataRepository.CustomersProvider.Insert(tm, mockCustomersByCustomerId); mock.CustomerId = mockCustomersByCustomerId.CustomerId; }
public void UpdateCustomerCustomerDemo(CustomerCustomerDemo customerCustomerDemo) { try { _context.CustomerCustomerDemo.Update(customerCustomerDemo); _context.SaveChanges(); } catch (Exception e) { throw new Exception(); } }
public async Task <IActionResult> Create([Bind("CustomerId,CustomerTypeId")] CustomerCustomerDemo customerCustomerDemo) { if (ModelState.IsValid) { _context.Add(customerCustomerDemo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "CustomerId", customerCustomerDemo.CustomerId); ViewData["CustomerTypeId"] = new SelectList(_context.CustomerDemographics, "CustomerTypeId", "CustomerTypeId", customerCustomerDemo.CustomerTypeId); return(View(customerCustomerDemo)); }
public async Task <CustomerCustomerDemo> CreateCustomerCustomerDemo(CustomerCustomerDemo customerCustomerDemo) { try { context.CustomerCustomerDemos.Add(customerCustomerDemo); context.SaveChanges(); } catch (Exception ex) { return(null); } return(customerCustomerDemo); }
public CustomerCustomerDemoProxyStub CustomerCustomerDemo_QueryForEntity(string serializedQuery) { CustomerCustomerDemoQuery query = CustomerCustomerDemoQuery.SerializeHelper.FromXml( serializedQuery, typeof(CustomerCustomerDemoQuery), AllKnownTypes) as CustomerCustomerDemoQuery; CustomerCustomerDemo obj = new CustomerCustomerDemo(); if (obj.Load(query)) { return(obj); } return(null); }
public CustomerCustomerDemo CustomerCustomerDemo_SaveEntity(CustomerCustomerDemo entity) { if (entity != null) { entity.Save(); if (entity.RowState != esDataRowState.Deleted && entity.RowState != esDataRowState.Invalid) { return(entity); } } return(null); }
public void UpdateCustomerCustomerDemo(inCustomerCustomerDemo inCustomerCustomerDemo) { try { CustomerCustomerDemo customerCustomerDemo = new CustomerCustomerDemo() { CustomerId = inCustomerCustomerDemo.CustomerID, CustomerTypeId = inCustomerCustomerDemo.CustomerTypeID }; iCustomerCustomerDemoDAO.UpdateCustomerCustomerDemo(customerCustomerDemo); } catch (Exception e) { throw new Exception(); } }
public CustomerCustomerDemo getCustomerCustomerDemoById(string customerID, string CustomerTypeID) { CustomerCustomerDemo customerCustomerDemo = new CustomerCustomerDemo(); Connection conn = new Connection(); SqlConnection connection = conn.SqlConnection; SqlCommand selectCommand = new SqlCommand(); selectCommand.Connection = connection; selectCommand.CommandType = CommandType.StoredProcedure; selectCommand.CommandText = "GetCustomerCustomerDemoById"; selectCommand.Parameters.Add("@CustomerID", SqlDbType.NChar); selectCommand.Parameters.Add("@CustomerTypeID", SqlDbType.NChar); selectCommand.Parameters["@CustomerID"].Value = customerID; selectCommand.Parameters["@CustomerTypeID"].Value = CustomerTypeID; { try { connection.Open(); SqlDataReader dataReader = selectCommand.ExecuteReader(); if (dataReader.HasRows) { dataReader.Read(); customerCustomerDemo.CustomerID = dataReader.GetString(0); customerCustomerDemo.CustomerTypeID = dataReader.GetString(1); } dataReader.Close(); } catch (Exception exc) { logger.logError(DateTime.Now, "Error while trying to get CustomerCustomerDemo with CustomerID = " + customerID + " and CustomerTypeID = " + CustomerTypeID + "."); MessageBox.Show(exc.Message); } finally { connection.Close(); } logger.logInfo(DateTime.Now, "GetCustomerCustomerDemoById method has sucessfully invoked."); return(customerCustomerDemo); } }
public IList <CustomerCustomerDemo> GetAll() { List <CustomerCustomerDemo> Customers = new List <CustomerCustomerDemo>(); db.Open(); string sql = "SELECT *FROM CustomerCustomerDemo"; db.InitCommand(sql, CommandType.Text); SqlDataReader reader = db.ExecuteReader(); while (reader.Read()) { CustomerCustomerDemo customerCustomerDemo = customerCustomerDemo = MapData(reader); Customers.Add(customerCustomerDemo); } db.Close(); return(Customers); }
public CustomerCustomerDemo GetByID(string id) { CustomerCustomerDemo Customer = null; db.Open(); string sql = "SELECT *FROM CustomerCustomerDemo WHERE CustomerID='" + id + "'"; db.InitCommand(sql, CommandType.Text); //db.AddInputParameter(DbType.String, "@Id", id); SqlDataReader reader = db.ExecuteReader(); if (reader.Read()) { Customer = MapData(reader); } db.Close(); return(Customer); }
///<summary> /// Returns a Typed CustomerCustomerDemo Entity with mock values. ///</summary> public static CustomerCustomerDemo CreateMockInstance_Generated(TransactionManager tm) { CustomerCustomerDemo mock = new CustomerCustomerDemo(); //OneToOneRelationship CustomerDemographics mockCustomerDemographicsByCustomerTypeId = CustomerDemographicsTest.CreateMockInstance(tm); DataRepository.CustomerDemographicsProvider.Insert(tm, mockCustomerDemographicsByCustomerTypeId); mock.CustomerTypeId = mockCustomerDemographicsByCustomerTypeId.CustomerTypeId; //OneToOneRelationship Customers mockCustomersByCustomerId = CustomersTest.CreateMockInstance(tm); DataRepository.CustomersProvider.Insert(tm, mockCustomersByCustomerId); mock.CustomerId = mockCustomersByCustomerId.CustomerId; // create a temporary collection and add the item to it TList<CustomerCustomerDemo> tempMockCollection = new TList<CustomerCustomerDemo>(); tempMockCollection.Add(mock); tempMockCollection.Remove(mock); return (CustomerCustomerDemo)mock; }
public static CustomerCustomerDemo ToDto(this CustomerCustomerDemoEntity entity, Hashtable seenObjects, Hashtable parents) { OnBeforeEntityToDto(entity, seenObjects, parents); var dto = new CustomerCustomerDemo(); if (entity != null) { if (seenObjects == null) { seenObjects = new Hashtable(); } seenObjects[entity] = dto; parents = new Hashtable(parents) { { entity, null } }; // Map dto properties dto.CustomerId = entity.CustomerId; dto.CustomerTypeId = entity.CustomerTypeId; // Map dto associations // n:1 Customer association if (entity.Customer != null) { dto.Customer = entity.Customer.RelatedObject(seenObjects, parents); } // n:1 CustomerDemographic association if (entity.CustomerDemographic != null) { dto.CustomerDemographic = entity.CustomerDemographic.RelatedObject(seenObjects, parents); } } OnAfterEntityToDto(entity, seenObjects, parents, dto); return(dto); }
public static CustomerCustomerDemo[] RelatedArray(this EntityCollection <CustomerCustomerDemoEntity> entities, Hashtable seenObjects, Hashtable parents) { if (null == entities) { return(null); } var arr = new CustomerCustomerDemo[entities.Count]; var i = 0; foreach (var entity in entities) { if (parents.Contains(entity)) { // - avoid all cyclic references and return null // - another option is to 'continue' and just disregard this one entity; however, // if this is a collection this would lead the client app to believe that other // items are part of the collection and not the parent item, which is misleading and false // - it is therefore better to just return null, indicating nothing is being retrieved // for the property all-together return(null); } } foreach (var entity in entities) { if (seenObjects.Contains(entity)) { arr[i++] = seenObjects[entity] as CustomerCustomerDemo; } else { arr[i++] = entity.ToDto(seenObjects, parents); } } return(arr); }
static partial void OnAfterDtoToEntity(CustomerCustomerDemo dto, CustomerCustomerDemoEntity entity);
public void DeleteCustomerCustomerDemo(CustomerCustomerDemo customerCustomerDemo) { this.DataContext.CustomerCustomerDemos.Attach(customerCustomerDemo); this.DataContext.CustomerCustomerDemos.DeleteOnSubmit(customerCustomerDemo); }
/// <summary> /// Serialize the mock CustomerCustomerDemo entity into a temporary file. /// </summary> private void Step_06_SerializeEntity_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_CustomerCustomerDemo.xml"); EntityHelper.SerializeXml(mock, fileName); Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock not found"); System.Console.WriteLine("mock correctly serialized to a temporary file."); } }
/// <summary> /// Make any alterations necessary (i.e. for DB check constraints, special test cases, etc.) /// </summary> /// <param name="mock">Object to be modified</param> private static void SetSpecialTestData(CustomerCustomerDemo mock) { //Code your changes to the data object here. }
/// <summary> /// There are no comments for CustomerCustomerDemo in the schema. /// </summary> public void AddToCustomerCustomerDemo(CustomerCustomerDemo customerCustomerDemo) { base.AddObject("CustomerCustomerDemo", customerCustomerDemo); }
public void Insert(string CustomerID,string CustomerTypeID) { CustomerCustomerDemo item = new CustomerCustomerDemo(); item.CustomerID = CustomerID; item.CustomerTypeID = CustomerTypeID; item.Save(UserName); }
public void Update(string CustomerID,string CustomerTypeID) { CustomerCustomerDemo item = new CustomerCustomerDemo(); item.MarkOld(); item.IsLoaded = true; item.CustomerID = CustomerID; item.CustomerTypeID = CustomerTypeID; item.Save(UserName); }
private void detach_CustomerCustomerDemo(CustomerCustomerDemo entity) { this.SendPropertyChanging(); entity.Customers = null; }
private void attach_CustomerCustomerDemo(CustomerCustomerDemo entity) { this.SendPropertyChanging(); entity.CustomerDemographics = this; }
/// <summary> /// Deep load all CustomerCustomerDemo children. /// </summary> private void Step_03_DeepLoad_Generated() { using (TransactionManager tm = CreateTransaction()) { int count = -1; mock = CreateMockInstance(tm); mockCollection = DataRepository.CustomerCustomerDemoProvider.GetPaged(tm, 0, 10, out count); DataRepository.CustomerCustomerDemoProvider.DeepLoading += new EntityProviderBaseCore<CustomerCustomerDemo, CustomerCustomerDemoKey>.DeepLoadingEventHandler( delegate(object sender, DeepSessionEventArgs e) { if (e.DeepSession.Count > 3) e.Cancel = true; } ); if (mockCollection.Count > 0) { DataRepository.CustomerCustomerDemoProvider.DeepLoad(tm, mockCollection[0]); System.Console.WriteLine("CustomerCustomerDemo instance correctly deep loaded at 1 level."); mockCollection.Add(mock); // DataRepository.CustomerCustomerDemoProvider.DeepSave(tm, mockCollection); } //normally one would commit here //tm.Commit(); //IDisposable will Rollback Transaction since it's left uncommitted } }
public async Task <IActionResult> PutCustomerCustomerDemo([FromRoute] string id, [FromBody] CustomerCustomerDemo customerCustomerDemo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customerCustomerDemo.CustomerId) { return(BadRequest()); } _context.Entry(customerCustomerDemo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerCustomerDemoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
protected async void Form0Submit(CustomerCustomerDemo args) { var northwindCreateCustomerCustomerDemoResult = await Northwind.CreateCustomerCustomerDemo(customercustomerdemo); DialogService.Close(customercustomerdemo); }
static partial void OnBeforeDtoToEntity(CustomerCustomerDemo dto);
static partial void OnAfterEntityToDto(CustomerCustomerDemoEntity entity, Hashtable seenObjects, Hashtable parents, CustomerCustomerDemo dto);
partial void UpdateCustomerCustomerDemo(CustomerCustomerDemo instance);
/// <summary> /// Create a new CustomerCustomerDemo object. /// </summary> /// <param name="customerCustomerDemoID">Initial value of CustomerCustomerDemoID.</param> public static CustomerCustomerDemo CreateCustomerCustomerDemo(string customerCustomerDemoID) { CustomerCustomerDemo customerCustomerDemo = new CustomerCustomerDemo(); customerCustomerDemo.CustomerCustomerDemoID = customerCustomerDemoID; return customerCustomerDemo; }
partial void DeleteCustomerCustomerDemo(CustomerCustomerDemo instance);
/// <summary> /// Serialize a CustomerCustomerDemo collection into a temporary file. /// </summary> private void Step_08_SerializeCollection_Generated() { using (TransactionManager tm = CreateTransaction()) { string fileName = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "temp_CustomerCustomerDemoCollection.xml"); mock = CreateMockInstance(tm); TList<CustomerCustomerDemo> mockCollection = new TList<CustomerCustomerDemo>(); mockCollection.Add(mock); EntityHelper.SerializeXml(mockCollection, fileName); Assert.IsTrue(System.IO.File.Exists(fileName), "Serialized mock collection not found"); System.Console.WriteLine("TList<CustomerCustomerDemo> correctly serialized to a temporary file."); } }
protected async void Form0Submit(CustomerCustomerDemo args) { var northwindUpdateCustomerCustomerDemoResult = await Northwind.UpdateCustomerCustomerDemo($"{CustomerID}", $"{CustomerTypeID}", customercustomerdemo); DialogService.Close(customercustomerdemo); }
/// <summary> /// Test methods exposed by the EntityHelper class. /// </summary> private void Step_20_TestEntityHelper_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); CustomerCustomerDemo entity = mock.Copy() as CustomerCustomerDemo; entity = (CustomerCustomerDemo)mock.Clone(); Assert.IsTrue(CustomerCustomerDemo.ValueEquals(entity, mock), "Clone is not working"); } }
public void InsertCustomerCustomerDemo(CustomerCustomerDemo customerCustomerDemo) { this.DataContext.CustomerCustomerDemos.InsertOnSubmit(customerCustomerDemo); }
partial void InsertCustomerCustomerDemo(CustomerCustomerDemo instance);
public void UpdateCustomerCustomerDemo(CustomerCustomerDemo currentCustomerCustomerDemo) { this.DataContext.CustomerCustomerDemos.Attach(currentCustomerCustomerDemo, this.ChangeSet.GetOriginal(currentCustomerCustomerDemo)); }