public void TestQueryOperations() { var demographics = new CustomerDemographics[] { new CustomerDemographics { CustomerTypeID = "IT", CustomerDesc = "Computer Science" }, new CustomerDemographics { CustomerTypeID = "EE", CustomerDesc = "Electrical Engineering" }, }; demographics.InsertOrUpdate(); new CustomerCustomerDemo { CustomerID = "ALFKI", CustomerTypeID = "IT", }.AsEnumerable().InsertOrUpdate(); var desc = Query.Select <CustomerDemographics>(row => row.CustomerTypeID == "IT").First().CustomerDesc; Debug.Assert(desc == "Computer Science"); var customer = Query.Select <CustomerCustomerDemo>(row => row.CustomerTypeID == "IT").First(); Debug.Assert(customer.CustomerID == "ALFKI"); }
public async Task <IActionResult> PostCustomerDemographics([FromBody] CustomerDemographics customerDemographics) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.CustomerDemographics.Add(customerDemographics); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (CustomerDemographicsExists(customerDemographics.CustomerTypeId)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetCustomerDemographics", new { id = customerDemographics.CustomerTypeId }, customerDemographics)); }
public void addCustomerDemographics() { CustomerDemographics customerDemographics = new CustomerDemographics("Regulary"); string res = repo.addCustomerDemographics(customerDemographics); Assert.IsNotNull(res); }
public async Task <IActionResult> Edit(string id, [Bind("CustomerTypeId,CustomerDesc")] CustomerDemographics customerDemographics) { if (id != customerDemographics.CustomerTypeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customerDemographics); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerDemographicsExists(customerDemographics.CustomerTypeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(customerDemographics)); }
public List <CustomerDemographics> getAllCustomerDemographics() { List <CustomerDemographics> customerDemographicsList = new List <CustomerDemographics>(); Connection conn = new Connection(); SqlConnection connection = conn.SqlConnection; using (SqlCommand command = new SqlCommand("select * from CustomerDemographics", connection)) { try { connection.Open(); SqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { CustomerDemographics customerDemographics = new CustomerDemographics(dataReader.GetString(0)); customerDemographics.CustomerDesc = dataReader.IsDBNull(1) ? (string)null : dataReader.GetString(1); customerDemographicsList.Add(customerDemographics); } dataReader.Close(); } catch (Exception exc) { logger.logError(DateTime.Now, "Error while trying to get all CustomerDemographics."); MessageBox.Show(exc.Message); } logger.logInfo(DateTime.Now, "GetAllCustomerDemographics method has sucessfully invoked."); return(customerDemographicsList); } }
public void updateCustomerDemographics() { CustomerDemographics customerDemographics = new CustomerDemographics("Regulary", "nesto drugo"); string res = repo.updateCustomerDemographics(customerDemographics); Assert.IsNotNull(res); }
public CustomerDemographics MapData(SqlDataReader reader) { CustomerDemographics cd = new CustomerDemographics(); cd.CustomerTypeID = reader["CustomerTypeID"].ToString(); cd.CustomerDesc = reader["CustomerDesc"].ToString(); return(cd); }
public ActionResult DeleteConfirmed(string id) { CustomerDemographics customerDemographics = db.CustomerDemographics.Find(id); db.CustomerDemographics.Remove(customerDemographics); db.SaveChanges(); return(RedirectToAction("Index")); }
///<summary> /// Update the Typed CustomerDemographics Entity with modified mock values. ///</summary> public static void UpdateMockInstance(TransactionManager tm, CustomerDemographics mock) { CustomerDemographicsTest.UpdateMockInstance_Generated(tm, mock); // make any alterations necessary // (i.e. for DB check constraints, special test cases, etc.) SetSpecialTestData(mock); }
public CustomerDemographicsProxyStub CustomerDemographics_GetByPrimaryKey(System.String customerTypeID) { CustomerDemographics obj = new CustomerDemographics(); if (obj.LoadByPrimaryKey(customerTypeID)) { return(obj); } return(null); }
public ActionResult Edit([Bind(Include = "CustomerTypeID,CustomerDesc")] CustomerDemographics customerDemographics) { if (ModelState.IsValid) { db.Entry(customerDemographics).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customerDemographics)); }
public async Task <IActionResult> Create([Bind("CustomerTypeId,CustomerDesc")] CustomerDemographics customerDemographics) { if (ModelState.IsValid) { _context.Add(customerDemographics); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(customerDemographics)); }
public ActionResult Create([Bind(Include = "CustomerTypeID,CustomerDesc")] CustomerDemographics customerDemographics) { if (ModelState.IsValid) { db.CustomerDemographics.Add(customerDemographics); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customerDemographics)); }
public void UpdateCustomerDemographics(CustomerDemographics customerDemographics) { try { _context.CustomerDemographics.Update(customerDemographics); _context.SaveChanges(); } catch (Exception e) { throw new Exception(); } }
public CustomerDemographics CustomerDemographics_SaveEntity(CustomerDemographics entity) { if (entity != null) { entity.Save(); if (entity.RowState != esDataRowState.Deleted && entity.RowState != esDataRowState.Invalid) { return(entity); } } return(null); }
// GET: CustomerDemographics/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomerDemographics customerDemographics = db.CustomerDemographics.Find(id); if (customerDemographics == null) { return(HttpNotFound()); } return(View(customerDemographics)); }
public CustomerDemographicsProxyStub CustomerDemographics_QueryForEntity(string serializedQuery) { CustomerDemographicsQuery query = CustomerDemographicsQuery.SerializeHelper.FromXml( serializedQuery, typeof(CustomerDemographicsQuery), AllKnownTypes) as CustomerDemographicsQuery; CustomerDemographics obj = new CustomerDemographics(); if (obj.Load(query)) { return(obj); } return(null); }
public void UpdateCustomerDemographics(inCustomerDemographics inCustomerDemographics) { try { CustomerDemographics customerDemographics = new CustomerDemographics() { CustomerTypeId = inCustomerDemographics.CustomerTypeID, CustomerDesc = inCustomerDemographics.CustomerDesc }; iCustomerDemographicsDAO.UpdateCustomerDemographics(customerDemographics); } catch (Exception e) { throw new Exception(); } }
public CustomerDemographics GetByID(string id) { CustomerDemographics cd = null; db.Open(); string sql = "SELECT *FROM CustomerDemographics WHERE CustomerTypeID='" + id + "'"; db.InitCommand(sql, CommandType.Text); //db.AddInputParameter(DbType.String, "@Id", id); SqlDataReader reader = db.ExecuteReader(); if (reader.Read()) { cd = MapData(reader); } db.Close(); return(cd); }
// GET: CustomerDemographics/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomerDemographics customerDemographics = db.CustomerDemographics.Find(id); if (customerDemographics == null) { return(HttpNotFound()); } else { customerDemographics.CustomerTypeID = customerDemographics.CustomerTypeID.TrimEnd(' '); } return(View(customerDemographics)); }
public IList <CustomerDemographics> GetAll() { List <CustomerDemographics> cdList = new List <CustomerDemographics>(); db.Open(); string sql = "SELECT *FROM CustomerDemographics"; db.InitCommand(sql, CommandType.Text); SqlDataReader reader = db.ExecuteReader(); while (reader.Read()) { CustomerDemographics cd = cd = MapData(reader); cdList.Add(cd); } db.Close(); return(cdList); }
public CustomerDemographics getCustomerDemographicsById(string CustomerTypeID) { CustomerDemographics customerDemographics = new CustomerDemographics(); Connection conn = new Connection(); SqlConnection connection = conn.SqlConnection; SqlCommand selectCommand = new SqlCommand(); selectCommand.Connection = connection; selectCommand.CommandType = CommandType.StoredProcedure; selectCommand.CommandText = "GetCustomerDemographicsById"; selectCommand.Parameters.Add("@CustomerTypeID", SqlDbType.NChar); selectCommand.Parameters["@CustomerTypeID"].Value = CustomerTypeID; { try { connection.Open(); SqlDataReader dataReader = selectCommand.ExecuteReader(); if (dataReader.HasRows) { dataReader.Read(); customerDemographics.CustomerTypeID = dataReader.GetString(0); customerDemographics.CustomerDesc = dataReader.IsDBNull(1) ? (string)null : dataReader.GetString(1); } dataReader.Close(); } catch (Exception exc) { logger.logError(DateTime.Now, "Error while trying to get CustomerDemographics with CustomerTypeID = " + CustomerTypeID + "."); MessageBox.Show(exc.Message); } finally { connection.Close(); } logger.logInfo(DateTime.Now, "GetCustomerDemographicsById method has sucessfully invoked."); return(customerDemographics); } }
private void CopyCustomerDemographics(IOdb odb) { //Processing CustomerDemographics LogMessage("Reading CustomerDemographics...", false); var adapter1 = new CustomerDemographicsTableAdapter(); var table1 = adapter1.GetData(); LogMessage("processing " + table1.Count.ToString() + " rows", true); foreach (var row in table1) { LogMessage("CustomerDemographics: " + row.CustomerTypeID + " ...", false); var cd = new CustomerDemographics { CustomerTypeID = row.CustomerTypeID, CustomerDesc = row.IsCustomerDescNull() ? null : row.CustomerDesc }; odb.Store(cd); LogMessage("saved", true); } odb.Commit(); LogMessage("Commit done, starting create index ...", false); odb.IndexManagerFor <CustomerDemographics>().AddUniqueIndexOn( "CustomerDemographics_CustomerTypeID_PK_index", CustomerDemographics.PK); odb.Commit(); LogMessage(" index created.", true); long objectCount = NDbUtil.GetAllInstances <CustomerDemographics>(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 CustomerDemographics" + Environment.NewLine, true); }
public ActionResult Delete(string CustomerTypeID, string CustomerID) { if ((CustomerTypeID == null) || (CustomerID == null)) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } CustomerDemographics customerDemographics = db.CustomerDemographics.Find(CustomerTypeID); if (customerDemographics == null) { return HttpNotFound(); } else { //System.Diagnostics.Debug.WriteLine(CustomerTypeID + " || " + CustomerID); db.CustomerDemographics.Find(CustomerTypeID).Customers.Remove(db.Customers.Find(CustomerID)); } db.SaveChanges(); return Redirect("Index"); }
public string addCustomerDemographics(CustomerDemographics customerDemographics) { Connection conn = new Connection(); SqlConnection connection = conn.SqlConnection; SqlCommand insertCommand = new SqlCommand(); insertCommand.Connection = connection; insertCommand.CommandType = CommandType.StoredProcedure; insertCommand.CommandText = "AddCustomerDemographics"; insertCommand.Parameters.Add("@CustomerTypeID", SqlDbType.NChar); insertCommand.Parameters.Add("@CustomerDesc", SqlDbType.NText); insertCommand.Parameters["@CustomerTypeID"].Value = customerDemographics.CustomerTypeID; insertCommand.Parameters["@CustomerDesc"].Value = customerDemographics.CustomerDesc; string index = null; try { connection.Open(); index = Convert.ToString(insertCommand.ExecuteScalar()); logger.logInfo(DateTime.Now, "AddCustomerDemographics method has sucessfully invoked."); return(index); } catch (Exception ex) { logger.logError(DateTime.Now, "Error while trying to add new CustomerDemographics."); MessageBox.Show(ex.Message); return(index); } finally { connection.Close(); } }
public MVCResult <CustomerDemographics> GetCustomerDemographics(CustomerDemographics model) { return(CRUD <CustomerDemographics> .Get(model)); }
public void getCustomerDemographicsById() { CustomerDemographics customerDemographics = repo.getCustomerDemographicsById("Usuall"); Assert.IsNotNull(customerDemographics); }
/// <summary> /// Create a new CustomerDemographics object. /// </summary> /// <param name="customerTypeID">Initial value of CustomerTypeID.</param> public static CustomerDemographics CreateCustomerDemographics(string customerTypeID) { CustomerDemographics customerDemographics = new CustomerDemographics(); customerDemographics.CustomerTypeID = customerTypeID; return customerDemographics; }
/// <summary> /// There are no comments for CustomerDemographics in the schema. /// </summary> public void AddToCustomerDemographics(CustomerDemographics customerDemographics) { base.AddObject("CustomerDemographics", customerDemographics); }
public MVCResult <string> InsertCustomerDemographics(CustomerDemographics model) { return(CRUD <CustomerDemographics> .Add(model)); }
public MVCResult <string> DeleteCustomerDemographics(CustomerDemographics model) { return(CRUD <CustomerDemographics> .Delete(model)); }
public override IQueryable <Customers> GetCustomerDemographicsCustomers(CustomerDemographics customerDemographics) { return(customerDemographics.Customers.AsQueryable()); }
public async Task <IActionResult> PutCustomerDemographics([FromRoute] string id, [FromBody] CustomerDemographics customerDemographics) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customerDemographics.CustomerTypeId) { return(BadRequest()); } _context.Entry(customerDemographics).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerDemographicsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <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(CustomerDemographics mock) { //Code your changes to the data object here. }
partial void DeleteCustomerDemographics(CustomerDemographics instance);
partial void UpdateCustomerDemographics(CustomerDemographics instance);
partial void InsertCustomerDemographics(CustomerDemographics instance);