public async Task <IActionResult> PutDbCustomerCredentials(string username, CustomerCredentials credentials) { if (username != credentials.Customer.Username) { return(BadRequest()); } DbCustomer customer = new DbCustomer(); customer.toDbCustomer((Customer)credentials.Customer); _context.Entry(customer).State = EntityState.Modified; DbContactInfo ci = new DbContactInfo(); ci.toDbContactInfo(credentials.Customer.ContactInfo, username); _context.Entry(ci).State = EntityState.Modified; DbCustomerCredentials dbCustomerCredentials = new DbCustomerCredentials(); dbCustomerCredentials.toDbCustomerCredentials(credentials); _context.Entry(dbCustomerCredentials).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { } return(NoContent()); }
public bool adminEditCustomer(Customer customer) { using (var db = new BankDBContext()) { try { DbCustomer dbcustomer = db.Customers.FirstOrDefault(c => c.NID == customer.nID); if (dbcustomer != null) { dbcustomer.firstName = customer.firstName; dbcustomer.lastName = customer.lastName; string salt = BankCustomerDAL.generateSalt(); string passwordAndSalt = customer.password + salt; byte[] hashedpassword = BankCustomerDAL.generateHash(passwordAndSalt); dbcustomer.password = hashedpassword; dbcustomer.salt = salt; db.SaveChanges(); return(true); } } catch (Exception e) { BankCustomerDAL.errorReport(e.ToString()); return(false); } return(false); } }
public bool adminRegisterCustomer(Customer inCustomer) { try { var newCustomer = new DbCustomer() { firstName = inCustomer.firstName, lastName = inCustomer.lastName, NID = inCustomer.nID }; var db = new BankDBContext(); string salt = BankCustomerDAL.generateSalt(); string passwordAndSalt = inCustomer.password + salt; byte[] hashedpassword = BankCustomerDAL.generateHash(passwordAndSalt); newCustomer.password = hashedpassword; newCustomer.salt = salt; db.Customers.Add(newCustomer); db.SaveChanges(); return(true); } catch (Exception e) { BankCustomerDAL.errorReport(e.ToString()); return(false); } }
public IHttpActionResult GetPage([FromUri] string senderID) { if (!LoggedUsers.Contains(senderID)) { return(Content(HttpStatusCode.Unauthorized, "Not logged in.")); } try { if (DbAdmin.Exists(senderID)) { return(Ok("./Content/partials/adminProfile.html")); } else if (DbDriver.Exists(senderID)) { return(Ok("./Content/partials/driverProfile.html")); } else if (DbCustomer.Exists(senderID)) { return(Ok("./Content/partials/customerProfile.html")); } else { return(NotFound()); } } catch (Exception e) { Trace.Write($"Error on 'Login()'. Error message: {e.Message}"); Trace.Write($"[STACK_TRACE] {e.StackTrace}"); return(InternalServerError(e)); } }
public bool ingresoCliente() { DbCustomer customer = new DbCustomer(); customer.CardNum = cardNum; customer.Description = txtRazonSocial.Text; customer.Street = txtDireccion.Text; customer.Notes1 = txtComuna.Text; customer.City = txtCiudad.Text; customer.Notes2 = txtDirecPostal.Text; customer.Notes3 = txtComPostal.Text; customer.Notes4 = txtCiudadPostal.Text; customer.Type = DbCustomer.Types.Identification; customer.VisibilityCriteriaID = 1; customer.PrepayPaymentID = 4; customer.PrepayPricelevelID = 1; customer.CreditPaymentID = 4; customer.CreditPricelevelID = 1; customer.IdentificationPricelevelID = 1; customer["passwd"] = "*"; BL.DB.InsertCustomer(customer); if (BL.AddCustomer(null, customer.CardNum, true) == BLogic.AddCustomerResult.Ok) { BL.RefreshTransactionItems(); return(true); } return(false); }
private void btn_user_update_Click(object sender, EventArgs e) { Customer customer = new Customer(); customer.SetName(txtb_name.Text); customer.SetPassword(DbCustomer.get_customer_from_id(Customer.activeCustomer).GetPassword()); //bu aşamada parola güncellensin istemiyoruz eski parolayı tekrar yazdırıyorum. customer.SetTelephone_number(maskedtxtb_telephone.Text); customer.SetBirth_date(dateTimePicker1.Value); customer.SetImage(pictureBox_user.ImageLocation); customer.SetMoney(Convert.ToInt32(numericUpdown_money.Value)); DialogResult dialog = MessageBox.Show("Update changed fields.", "Okey", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialog == DialogResult.Yes) { if (string.IsNullOrEmpty(customer.GetName()) || string.IsNullOrEmpty(customer.GetPassword())) { MessageBox.Show("Username field is required. ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DbCustomer.UpdateCustomer(customer); MessageBox.Show("Updated!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public IHttpActionResult GetUsers([FromUri] string senderID) { List <IUser> result = new List <IUser>(); if (!LoggedUsers.Contains(senderID)) { return(Content(HttpStatusCode.Unauthorized, "Not logged in.")); } //other rights? try { (DbAdmin.GetAll()).ToList().ForEach(a => result.Add(a)); (DbCustomer.GetAll()).ToList().ForEach(c => result.Add(c)); (DbDriver.GetAll()).ToList().ForEach(d => result.Add(d)); } catch (Exception e) { Trace.Write($"Error on 'GetUsers()'. Error message: {e.Message}"); Trace.Write($"[STACK_TRACE] {e.StackTrace}"); return(InternalServerError(e)); } return(Ok(result)); }
private bool ValidateCustomerKafkaObject(dynamic source, KafkaMessage target, string customerType, bool isIncludeID, DbCustomer sourceCustomerDetail) { Enum.TryParse(customerType, out CustomerType custType); var json = JObject.Parse(JsonConvert.SerializeObject(target.Message)); dynamic eventMsg; if (!isIncludeID) { eventMsg = JsonConvert.DeserializeObject <CreateCustomerEvent>( json.SelectToken($"CreateCustomerEvent").ToString()); } else { eventMsg = JsonConvert.DeserializeObject <UpdateCustomerEvent>( json.SelectToken($"UpdateCustomerEvent").ToString()); } return(CustomerTopics.Contains(target.Topic) && source.CustomerUID.ToString() == target.Key && eventMsg.CustomerName == source.CustomerName && eventMsg.CustomerUID == source.CustomerUID && eventMsg.BSSID == source.BSSID && eventMsg.DealerNetwork == source.DealerNetwork && eventMsg.NetworkDealerCode == source.NetworkDealerCode && eventMsg.DealerAccountCode == source.DealerAccountCode && eventMsg.NetworkCustomerCode == source.NetworkCustomerCode && eventMsg.FirstName == source.FirstName && eventMsg.LastName == source.LastName && eventMsg.PrimaryContactEmail == source.PrimaryContactEmail && !isIncludeID ? true : sourceCustomerDetail.fk_CustomerTypeID == (int)custType); }
private Customer MapToCustomer(DbCustomer dbCustomer) { return new Customer( dbCustomer.CustomerID.Trim(), dbCustomer.CompanyName, dbCustomer.ContactName); }
public async Task <ActionResult <DbCustomerCredentials> > PostDbCustomerCredentials(CustomerCredentials credentials) { DbCustomerCredentials dbCustomerCredentials = new DbCustomerCredentials(); dbCustomerCredentials.toDbCustomerCredentials(credentials); _context.customerCredentials.Add(dbCustomerCredentials); DbCustomer cust = new DbCustomer(); cust.toDbCustomer((Customer)credentials.Customer); _context.customers.Add(cust); DbContactInfo ci = new DbContactInfo(); ci.toDbContactInfo(credentials.Customer.ContactInfo, credentials.Customer.Username); _context.contactInfo.Add(ci); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (DbCustomerCredentialsExists(dbCustomerCredentials.Username)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetDbCustomerCredentials", new { id = credentials.Customer.Username }, credentials)); //hi }
private bool ValidateCustomerUserObject(dynamic source, DbUserCustomer target, DbCustomer customerDetail) { return(target.fk_CustomerUID == source.CustomerUID && target.fk_UserUID == source.UserUID && target.fk_CustomerID == customerDetail.CustomerID); }
public ActionResult UpdateCustomer(FormCollection inList) { var db = new DbCustomer(); bool OK = db.EditCustomer(inList); if(OK) { return RedirectToAction("List"); } return View(); }
public ActionResult Reg(Customer inCustomer) { var db = new DbCustomer(); bool OK = db.saveCustomer(inCustomer); if (OK) { return RedirectToAction("List"); } return View(); }
private void btn_user_delete_Click(object sender, EventArgs e) { DialogResult dialog = MessageBox.Show("Are you sure to delete this account.", "Okey", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialog == DialogResult.Yes) { DbCustomer.DeleteProfile(); Customer.activeCustomer = 0; Application.Restart(); //Hesap silindi giriş sayfasına dön } }
private DbCustomer toDbCustomer(Customer customer) { var dbCustomer = new DbCustomer(); dbCustomer.Pkid = customer.Id; dbCustomer.FirstName = customer.FirstName; dbCustomer.LastName = customer.LastName; dbCustomer.Email = customer.Email; dbCustomer.Phone = customer.Phone; return(dbCustomer); }
private Customer toCustomer(DbCustomer dbCustomer) { var customer = new Customer(); customer.Id = dbCustomer.Pkid; customer.FirstName = dbCustomer.FirstName; customer.LastName = dbCustomer.LastName; customer.Email = dbCustomer.Email; customer.Phone = dbCustomer.Phone; return(customer); }
private void timer1_Tick(object sender, EventArgs e) { string clock = DateTime.Now.ToLongTimeString(); lbl_clock.Text = clock; if (Customer.activeCustomer != 0) { lbl_active_usermoney.Text = DbCustomer.get_customer_from_id(Customer.activeCustomer).GetMoney().ToString(); //menudeki para değiştiğinde güncelleyebilmek için } }
public IHttpActionResult PostCustomer([FromUri] string senderID, [FromBody] GeneralUserModel userModel) { Customer customer = new Customer(userModel.Username, userModel.Password) { FirstName = userModel.FirstName, LastName = userModel.LastName, Gender = userModel.Gender, JMBG = userModel.JMBG, Phone = userModel.Phone, Email = userModel.Email, }; userModel.TaxiDrivesIDs.ForEach(td => customer.TaxiDrives.Add(DbTaxiDrive.GetSingleEntityByKey(td))); //Customer ne pravi sam svoj nalog if (senderID != customer.Username) { if (!LoggedUsers.Contains(senderID)) { return(Content(HttpStatusCode.Unauthorized, "Not logged in.")); } else if (!DbAdmin.Exists(senderID)) { return(Content(HttpStatusCode.Unauthorized, "Not a dispatcher nor the user to be added.")); } } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } bool result; try { result = DbCustomer.Add(customer); } catch (Exception e) { Trace.Write($"Error on 'PostCustomer()'. Error message: {e.Message}"); Trace.Write($"[STACK_TRACE] {e.StackTrace}"); return(InternalServerError(e)); } if (result) { return(Ok(customer)); } else { return(BadRequest("Customer already exists.")); } }
public ActionResult Login() { var db = new DbCustomer(); bool loggedIn = db.Login(); if (loggedIn) { ViewBag.loggedin = true; //Forklar meg dette den so lagde det return RedirectToAction("List"); } return View(); //Implisitt else }
private void btn_Customerlogin_Click(object sender, EventArgs e) { Customer customer = new Customer(); customer.SetName(txtb_cl_Username.Text); customer.SetPassword(txtb_cl_Pasword.Text); if (DbCustomer.is_account_exist(customer)) { OpenPage.ActiveForm.Close(); } }
private void fill_user_details() { Customer customer = new Customer(); customer = DbCustomer.get_customer_from_id(Customer.activeCustomer); pictureBox_user.ImageLocation = customer.GetImage(); txtb_name.Text = customer.GetName(); maskedtxtb_telephone.Text = customer.GetTelephone_number(); dateTimePicker1.Text = customer.GetBirth_date().ToString(); numericUpdown_money.Value = Convert.ToDecimal(customer.GetMoney()); }
private void btn_addComment_Click(object sender, EventArgs e) { Comment comment = new Comment(); comment.SetText(richTxtb_commentText.Text); comment.SetCreateTime(DateTime.Now); comment.SetProduct(this.product); comment.SetCustomer(DbCustomer.get_customer_from_id(Customer.activeCustomer)); comment.SetSeller(DbSeller.get_seller_data_from_id(Seller.activeSeller)); DbComment.add_comment(comment); }
public Customer AddCustomer(Customer customer) { var dbContext = new DataContext(); var dbCustomer = new DbCustomer(); dbCustomer.DbCustomerId = customer.CustomerId; dbCustomer.Name = customer.Name; dbCustomer = dbContext.DbCustomers.Add(dbCustomer); dbContext.SaveChanges(); return(new Customer(dbCustomer)); }
/// <summary> /// Convert a DbCustomer into a domain Customer /// </summary> public static Customer FromDbCustomer(DbCustomer sqlCustomer) { if (sqlCustomer == null) { return(null); } var id = CustomerId.Create(sqlCustomer.Id); var name = PersonalName.Create(sqlCustomer.FirstName, sqlCustomer.LastName); var email = EmailAddress.Create(sqlCustomer.Email); var cust = Customer.Create(id, name, email); return(cust); }
public void UpdateCustomer_ValidPayload_TransactionSuccess( string customerType, bool hasActive, bool?isActive) { //Arrange var customerEvent = new UpdateCustomerEvent { CustomerName = $"{customerType}01", CustomerUID = Guid.NewGuid(), BSSID = "BSS01", DealerNetwork = "None", NetworkDealerCode = "NDC01", PrimaryContactEmail = $"{customerType}[email protected]", FirstName = $"{customerType}FN01", LastName = $"{customerType}LN01", ActionUTC = DateTime.UtcNow, ReceivedUTC = DateTime.UtcNow }; var custDetail = new DbCustomer { CustomerID = 1, CustomerUID = customerEvent.CustomerUID, fk_CustomerTypeID = 0, IsActive = true }; if (hasActive) { customerEvent.IsActive = isActive; } transaction.Execute(Arg.Any <List <Action> >()) .Returns(a => { a.Arg <List <Action> >().ForEach(action => action.Invoke()); return(true); }); //Act var resultData = customerService.UpdateCustomer(customerEvent, custDetail); //Assert Assert.True(resultData); transaction.Received(1).Upsert( Arg.Is <DbCustomer>(o => ValidateCustomerObject(customerEvent, o, customerType, true, hasActive, custDetail))); transaction.Received(1).Publish(Arg.Is <List <KafkaMessage> >(messages => messages.TrueForAll(m => ValidateCustomerKafkaObject(customerEvent, m, customerType, true, custDetail)))); }
public List <Customer> deleteCustomer(string nID) { var db = new BankDBContext(); try { DbCustomer deleteCustomer = db.Customers.FirstOrDefault(pk => pk.NID.Equals(nID)); if (deleteCustomer == null) { return(null); } IEnumerable <DbAccount> accounts = db.Accounts.Where(a => a.NID.Equals(nID)).ToList(); IEnumerable <DbRegisteredPayment> registeredPayments; IEnumerable <DbIssuedPayment> issuedPayments; foreach (DbAccount account in accounts) { registeredPayments = db.RegisteredPayments.Where(rp => rp.customerAccountNumber.Equals(account.accountNumber)).ToList(); issuedPayments = db.IssuedPayments.Where(ip => ip.customerAccountNumber.Equals(account.accountNumber)).ToList(); foreach (DbRegisteredPayment rp in registeredPayments) { db.RegisteredPayments.Remove(rp); db.SaveChanges(); } foreach (DbIssuedPayment ip in issuedPayments) { db.IssuedPayments.Remove(ip); db.SaveChanges(); } db.Accounts.Remove(account); db.SaveChanges(); } db.Customers.Remove(deleteCustomer); db.SaveChanges(); return(db.Customers.Select(c => new Customer() { nID = c.NID, firstName = c.firstName, lastName = c.lastName }) .ToList()); } catch (Exception e) { BankCustomerDAL.errorReport(e.ToString()); return(null); } }
public void AssociateCustomerAsset_ValidPayload_ExpectedTransactionStatus( bool hasValidCustomer, bool transactionStatus, int upsertCalls, int publishCalls, bool hasException, string relType) { //Arrange var customerUid = Guid.NewGuid(); var assetUid = Guid.NewGuid(); var assetCustomerEvent = new AssociateCustomerAssetEvent { CustomerUID = customerUid, AssetUID = assetUid, RelationType = relType, ActionUTC = DateTime.UtcNow, ReceivedUTC = DateTime.UtcNow }; DbCustomer customerData = hasValidCustomer ? new DbCustomer() { CustomerID = 109 } : null; transaction.Get <DbCustomer>(Arg.Any <string>()).Returns(new List <DbCustomer> { customerData }); transaction.Execute(Arg.Any <List <Action> >()) .Returns(a => { if (hasException) { a.Arg <List <Action> >().ForEach(action => action.Returns(e => throw new Exception())); return(false); } else { a.Arg <List <Action> >().ForEach(action => action.Invoke()); return(true); } }); //Act var resultData = customerAssetService.AssociateCustomerAsset(assetCustomerEvent); //Assert Assert.Equal(transactionStatus, resultData); transaction.Received(upsertCalls).Upsert( Arg.Is <DbAssetCustomer>(assetCust => ValidateCustomerAssetObject(assetCustomerEvent, assetCust))); transaction.Received(publishCalls).Publish( Arg.Is <List <KafkaMessage> >(messages => messages .TrueForAll(m => ValidateCustomerAssetKafkaObject(false, m, assetCustomerEvent)))); }
public void CreateUserCutsomerRelationship_GivenPayload_ExpectedStatus( CreateUserCustomerRelationshipEvent relationshipEvent, bool hasValidCustomer, bool transactionStatus, int upsertCalls, int publishCalls, bool hasException) { //Arrange DbCustomer customerData = hasValidCustomer ? new DbCustomer() { CustomerID = 109, CustomerUID = relationshipEvent.CustomerUID } : null; if (hasException) { transaction.Get <DbCustomer>(Arg.Any <string>()).Returns(e => throw new Exception()); } else { transaction.Get <DbCustomer>(Arg.Any <string>()).Returns(new List <DbCustomer> { customerData }); } transaction.Execute(Arg.Any <List <Action> >()) .Returns(a => { a.Arg <List <Action> >().ForEach(action => action.Invoke()); return(true); }); if (hasException) { Assert.Throws <Exception>(() => customerService.CreateUserCustomerRelationship(relationshipEvent)); } else { var resultData = customerService.CreateUserCustomerRelationship(relationshipEvent); Assert.Equal(transactionStatus, resultData); } //Assert transaction.Received(upsertCalls).Upsert( Arg.Is <DbUserCustomer>(userCust => ValidateCustomerUserObject(relationshipEvent, userCust, customerData))); transaction.Received(publishCalls).Publish( Arg.Is <List <KafkaMessage> >(messages => messages .TrueForAll(m => ValidateCustomerUserKafkaObject(false, false, m, relationshipEvent)))); }
private CustomerCredentials toUser(DbCustomerCredentials credential) { DbCustomer customer = _context.customers.Single(customer => customer.Username == credential.Username); if (customer == null) { return(null); } DbContactInfo contactInfo = _context.contactInfo.Single(contactInfo => contactInfo.Username == credential.Username); Customer cust; cust = customer.toCustomer(contactInfo); CustomerCredentials cc = new CustomerCredentials(credential.Password, cust); return(cc); }
public ActionResult AddOrder() { var db = new DbOrder(); var cdb = new DbCustomer(); Cart cart = (Cart)HttpContext.Session["Cart"]; int sumTotal = SumTotal(cart.productids); int customerID = cdb.CurrentCustomer(); Debug.Write("SumTotal" + sumTotal); int orderid = db.saveOrer(sumTotal, customerID); Debug.Print("Orderid: " + orderid); if (orderid!=0) { db.addOrderList(orderid); return RedirectToAction( "OrderComplete", "Orders"); } return RedirectToAction("Customer", "List"); }
public IHttpActionResult Login([FromBody] LoginModel loginModel) { if (LoggedUsers.Contains(loginModel.Username)) { return(Content(HttpStatusCode.Conflict, $"User '{loginModel.Username}' already logged in.")); } IUser result = null; try { if (DbAdmin.Exists(loginModel.Username)) { result = DbAdmin.GetSingleEntityByKey(loginModel.Username); } else if (DbDriver.Exists(loginModel.Username)) { result = DbDriver.GetSingleEntityByKey(loginModel.Username); } else if (DbCustomer.Exists(loginModel.Username)) { result = DbCustomer.GetSingleEntityByKey(loginModel.Username); } } catch (Exception e) { Trace.Write($"Error on 'Login()'. Error message: {e.Message}"); Trace.Write($"[STACK_TRACE] {e.StackTrace}"); return(InternalServerError(e)); } if (result == null) { return(NotFound()); } if (result.Password.Equals(loginModel.Password)) { LoggedUsers.Add(loginModel.Username); return(Ok(result)); } else { return(BadRequest($"Entered password did not match the required one for user '{loginModel.Username}'.")); } }
public void GetAssociatedCustomersbyUserUid_ValidUser_ReturnsCustomers() { //Arrange var userUid = Guid.NewGuid(); var customer1 = new DbCustomer { CustomerID = 1, CustomerUID = Guid.NewGuid(), CustomerName = "CUS01", fk_CustomerTypeID = 0, LastCustomerUTC = DateTime.UtcNow }; var customer2 = new DbCustomer { CustomerID = 2, CustomerUID = Guid.NewGuid(), CustomerName = "CUS02", fk_CustomerTypeID = 1, LastCustomerUTC = DateTime.UtcNow }; var customers = new List <DbCustomer> { customer1, customer2 }; var config = new ComparisonConfig { IgnoreObjectTypes = true, MaxMillisecondsDateDifference = 500, MaxDifferences = 0 }; var accountCompareLogic = new CompareLogic(config); transaction.Get <DbCustomer>(Arg.Any <string>()).Returns(customers); //Act var resultData = customerService.GetAssociatedCustomersbyUserUid(userUid); //Assert Assert.NotNull(resultData); Assert.Equal(2, resultData.Count); transaction.Received(1) .Get <DbCustomer>(Arg.Is <string>(q => q.Contains($"UNHEX('{userUid.ToString("N")}')"))); ComparisonResult compareResult = accountCompareLogic.Compare(customers, resultData); Assert.True(compareResult.Differences.Count == 0); }
// DELETE api/drivers/5 public IHttpActionResult DeleteUser([FromUri] string senderID, [FromUri] string userToDelete) { bool result = false; if (!LoggedUsers.Contains(senderID)) { return(Content(HttpStatusCode.Unauthorized, "Not logged in.")); } else if (!DbAdmin.Exists(senderID)) { return(Content(HttpStatusCode.Unauthorized, "Not a dispatcher.")); } try { if (DbAdmin.Exists(userToDelete)) { //TODO: sta ako obrise samog sebe logout? result = DbAdmin.Delete(userToDelete); } else if (DbDriver.Exists(userToDelete)) { result = DbDriver.Delete(userToDelete); } else if (DbCustomer.Exists(userToDelete)) { result = DbCustomer.Delete(userToDelete); } } catch (Exception e) { Trace.Write($"Error on 'DeleteUser()'. Error message: {e.Message}"); Trace.Write($"[STACK_TRACE] {e.StackTrace}"); return(InternalServerError(e)); } if (result) { return(Ok()); } else { return(NotFound()); } }
public IHttpActionResult GetNonDriver([FromUri] string senderID, [FromUri] string userIdToGet) { IUser result = null; if (!LoggedUsers.Contains(senderID)) { return(Content(HttpStatusCode.Unauthorized, "Not logged in.")); } try { if (DbAdmin.Exists(userIdToGet)) { if (!DbAdmin.Exists(senderID)) { return(Content(HttpStatusCode.Unauthorized, "Not a dispatcher.")); } result = DbAdmin.GetSingleEntityByKey(userIdToGet); } else if (DbCustomer.Exists(userIdToGet)) { if (!DbAdmin.Exists(senderID) || senderID != userIdToGet) { return(Content(HttpStatusCode.Unauthorized, "Not a dispatcher nor the user whose information are requested.")); } result = DbAdmin.GetSingleEntityByKey(userIdToGet); } } catch (Exception e) { Trace.Write($"Error on 'GetNonDriver()'. Error message: {e.Message}"); Trace.Write($"[STACK_TRACE] {e.StackTrace}"); return(InternalServerError(e)); } if (result == null) { return(NotFound()); } return(Ok(result)); }
public void GetOnlyAssociatedCustomersbyUserUid_GivenInput_ReturnsData() { //Arrange var userUid = Guid.NewGuid(); var customer = new DbCustomer { CustomerID = 1, CustomerUID = Guid.NewGuid(), CustomerName = "CUS01", fk_CustomerTypeID = 0, BSSID = "Store_123", DealerNetwork = "None", IsActive = true }; var account = new DbAccount { AccountName = "ACC01", CustomerAccountUID = Guid.NewGuid(), BSSID = "Store_123", DealerAccountCode = "DAC01", NetworkCustomerCode = "NCC01", fk_ChildCustomerUID = customer.CustomerUID }; var customerAccount = new List <Tuple <DbCustomer, DbAccount> > { new Tuple <DbCustomer, DbAccount>(customer, account) }; transaction.Get <DbCustomer, DbAccount>(Arg.Any <string>(), "AccountName") .Returns(customerAccount); //Act var result = customerService.GetOnlyAssociatedCustomersbyUserUid(userUid); //Assert Assert.NotNull(result); Assert.NotEmpty(result); transaction.Received(1).Get <DbCustomer, DbAccount>(Arg.Any <string>(), Arg.Is("AccountName")); transaction.Received(1).Get <DbCustomer, DbAccount>( Arg.Is <string>(q => q.Contains($"UNHEX('{userUid.ToString("N")}')")), Arg.Is("AccountName")); Assert.Equal(customer, result[0].Item1); Assert.Equal(account, result[0].Item2); }
public ActionResult List() { var db = new DbCustomer(); List<Customer> allCustomers = db.allCustomers(); return View(allCustomers); }
public ActionResult ValidateUser(FormCollection inList) { //Trenger feilmelding når brukervalidering feiler. var db = new DbCustomer(); bool loggedIn = db.ValidateUser(inList); if (loggedIn) { return RedirectToAction("List"); } return RedirectToAction("Login");//Implisitt else }