private void gridView4_RowCellClick(object sender, RowCellClickEventArgs e) { DevExpress.XtraGrid.Columns.GridColumn column = e.Column; GridView view = sender as GridView; if (column.Name == "btnDeletePassDay") { object _name = view.GetRowCellValue(e.RowHandle, "Name"); DialogResult dialog = XtraMessageBox.Show($"{_name} Seçili satır silinsin mi*", "Sil", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { try { object _Id = view.GetRowCellValue(e.RowHandle, "Id"); Customer deleteModel = new Customer() { Id = Convert.ToInt32(_Id.ToString()) }; getBusiness = new CustomerBusinessLayer(); getBusiness.Delete(deleteModel); } catch (Exception ex) { XtraMessageBox.Show("Veri silinemedi tekrar deneyiniz!"); } finally { FillGrid(); } } } }
public CustomerBusinessLayerTestFixture() { StorageProviderMock = new Mock <ICustomerStorageProvider>(); StorageProviderMock.Setup(mock => mock.AddCustomerAsync(It.IsAny <CustomerDto>())) .Returns(Task.CompletedTask); StorageProviderMock.Setup(mock => mock.DeleteCustomerAsync(It.IsAny <CustomerDto>())) .Returns(Task.CompletedTask); StorageProviderMock.Setup(mock => mock.GetAllCustomersAsync()) .Returns(_customerDtosTask); // We look for the specific Guid in the tests, so we have to be able to test for that exact one, // and all the others should return as a miss. StorageProviderMock.Setup(mock => mock.GetCustomerAsync(It.Is <Guid>(g => g.Equals(new Guid(CustomerGuid))))) .Returns(_customerDtoSingleTask); StorageProviderMock.Setup(mock => mock.GetCustomerAsync(It.Is <Guid>(g => !g.Equals(new Guid(CustomerGuid))))) .Returns(Task.FromResult <CustomerDto>(null)); // We want to look for this particular search term as that's what our models above match (in this mock). StorageProviderMock.Setup(mock => mock.SearchCustomersAsync(It.Is <string>(s => s.Equals(SearchTerm)))) .Returns(_customerDtosTask); StorageProviderMock.Setup(mock => mock.SearchCustomersAsync(It.Is <string>(s => !s.Equals(SearchTerm)))) .Returns(Task.FromResult(Enumerable.Empty <CustomerDto>())); StorageProviderMock.Setup(mock => mock.UpdateCustomerAsync(It.IsAny <CustomerDto>())) .Returns(Task.CompletedTask); CustomerBusinessLayer = new CustomerBusinessLayer(StorageProviderMock.Object, CustomerMapper); }
private void DayOverSendMail() { try { getBusiness = new CustomerBusinessLayer(); var list = getBusiness.GetAll(); List <Customer> passPaymentDateList = new List <Customer>(); List <Customer> _CustomerGridList = new List <Customer>(); getSendMailBusiness = new SendMailBusinessLayer(); //Mail data = new Mail() //{ // From = txtMailAdress.Text.ToString(), // Password = txtMailPassword.Text.ToString(), // Port = Convert.ToInt32(txtMailSmtpPort.Text.ToString()), // Subject = txtMailSubject.Text.ToString(), // Body = txtMailContent.Text.ToString(), // ToAdd = txtMailRecever.Text.ToString(), // SmtpServer = txtSmtpServer.Text.ToString(), // ShopName = txtCompanyName.Text.ToString() //}; getBusiness = new CustomerBusinessLayer(); var customerList = getBusiness.GetAll(); var mailInformation = getSendMailBusiness.GetAll(); Mail mailData = null; foreach (var item in mailInformation) { mailData = new Mail() { Body = item.Body, From = item.From, Password = item.Password, ShopName = item.ShopName, SmtpServer = item.SmtpServer, Port = item.Port, Subject = item.Subject }; } foreach (var item in customerList) { // Aslında Aşağıdaki 2. Kod satırı kullanıcı insafiyetine bırakılabilir!! if (item.PassPaymentDate < DateTime.Now && item.LastSendMailDate.AddDays(+7) < DateTime.Now) { getSendMailBusiness.MailsendCustomer(mailData, item); } } } catch (Exception ex) { MessageBox.Show("Günü geçenlere otomatik mail gönderme hatası UI " + ex.Message); } }
public void Search(Customer item) { try { getBusiness = new CustomerBusinessLayer(); List <Customer> _searchData = new List <Customer>(); _searchData = getBusiness.Search(item); List <Customer> passData = new List <Customer>(); List <Customer> activeData = new List <Customer>(); foreach (var data in _searchData) { if (data.PassPaymentDate > DateTime.Now) { activeData.Add(data); } if (data.PassPaymentDate < DateTime.Now) { passData.Add(data); } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
// GET: Customer public ActionResult Details(int id) { CustomerBusinessLayer cusBl = new CustomerBusinessLayer(); CustomerModel cusModel = cusBl.GetCustomerDetails(id); return(View(cusModel)); }
public ActionResult Edit(int id) { CustomerBusinessLayer cusBl = new CustomerBusinessLayer(); CustomerModel cusModel = cusBl.DisplayEditCustomer(id); ViewData["CustomerMessage"] = ""; return(View(cusModel)); }
public void AddCustomerAsync_AddNewCustomer_AddsCustomer() { CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer; CustomerModel customerModel = CustomerBusinessLayerTestFixture.InputCustomerModel; Func <Task> test = async() => await businessLayer.AddCustomerAsync(customerModel); test.Should() .NotThrow(); }
public void AddCustomerAsync_AddExistingCustomer_ThrowsArgumentException() { CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer; CustomerModel customerModel = CustomerBusinessLayerTestFixture.CustomerModelWithId; Func <Task> test = async() => await businessLayer.AddCustomerAsync(customerModel); test.Should() .Throw <ArgumentException>(); }
public void UpdateCustomerAsync_UpdateCustomer_UpdatesCustomer() { CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer; CustomerModel customerModel = CustomerBusinessLayerTestFixture.InputCustomerModel; Guid id = new Guid(CustomerBusinessLayerTestFixture.CustomerGuid); Func <Task> test = async() => await businessLayer.UpdateCustomerAsync(id, customerModel); test.Should() .NotThrow(); }
public HttpResponseMessage Create(Customer customer) { var idAPIResult = new IdAPIResult() { Usage = "HttpPost:~/api/Customers with Customer json in body" }; idAPIResult.Id = CustomerBusinessLayer.CreateCustomer(customer); return(Request.CreateResponse(HttpStatusCode.OK, idAPIResult)); }
public void UpdateCustomerAsync_NonExistantCustomer_UpdatesCustomer() { CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer; CustomerModel customerModel = CustomerBusinessLayerTestFixture.InputCustomerModel; Guid id = Guid.NewGuid(); Func <Task> test = async() => await businessLayer.UpdateCustomerAsync(id, customerModel); test.Should() .Throw <ArgumentException>(); }
private void Delete(Customer model) { try { getBusiness = new CustomerBusinessLayer(); getBusiness.Delete(model); } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } }
public ActionResult Edit_Post(int id) { CustomerBusinessLayer cusBl = new CustomerBusinessLayer(); CustomerModel cusModel = new CustomerModel(); UpdateModel(cusModel); cusBl.EditCustomerDetails(id, cusModel.Name, cusModel.FatherName, cusModel.DateOfBirth, cusModel.Age, cusModel.MaritalStatus, cusModel.Address, cusModel.City, cusModel.State, cusModel.Country, cusModel.Pincode, cusModel.Phone, cusModel.EmailId); ViewData["CustomerMessage"] = "Changes Saved Successfully"; return(View()); }
public HttpResponseMessage Delete(int id) { var successAPIResult = new SuccessAPIResult() { Usage = "HttpDelete:~/api/Customers/{id} or {args} can be on querystring, {args?} are optional" }; successAPIResult.Successful = CustomerBusinessLayer.DeleteCustomer(id); if (!successAPIResult.Successful) { return(Request.CreateResponse(HttpStatusCode.NotFound, successAPIResult)); } return(Request.CreateResponse(HttpStatusCode.OK, successAPIResult)); }
protected void Application_Start() { var initDB = false; GlobalConfiguration.Configure(WebApiConfig.Register); CustomerBusinessLayer.Register(new DBLayer()); AgentBusinessLayer.Register(new DBLayer()); bool.TryParse(ConfigurationManager.AppSettings["InitDB"], out initDB); if (initDB) { InitDB(); } }
public List <CustomerViewModel> GetCustomerViewModelList() { CustomerBusinessLayer cutBL = new CustomerBusinessLayer(); List <Customer> customerList = cutBL.GetCustomer(); List <CustomerViewModel> cutLVM = new List <CustomerViewModel>(); foreach (Customer customer in customerList) { CustomerViewModel cutVM = new CustomerViewModel(); cutVM.CustomerName = customer.CustomerFirstName + " " + customer.CustomerLastName; cutVM.CustomerGender = customer.CustomerGender; cutVM.CustomerEmail = customer.CustomerEmail; cutVM.CustomerAddress = customer.CustomerStreetNum + " " + customer.CustomerStreetName + ", " + customer.CustomerProvince + ", " + customer.CustomerPostCode; cutVM.CustomerBillingMethod = customer.CustomerBillingMethod; cutLVM.Add(cutVM); } return(cutLVM); }
public void SearchCustomersAsync_CustomerNonExistant_ReturnsEmptyEnumerable() { CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer; string searchTerm = "John"; IEnumerable <CustomerModel> customerModels = _fixture.CustomerModels; IEnumerable <CustomerModel> customerModelsResult = Enumerable.Empty <CustomerModel>(); Func <Task> test = async() => { customerModelsResult = await businessLayer.SearchCustomersAsync(searchTerm); }; test.Should() .NotThrow(); customerModelsResult.Should() .BeEmpty(); }
public HttpResponseMessage Get(int agentId, int page = 1, int pageSize = 2) { var customerPagedListAPIResult = new CustomerPagedListAPIResult { Page = page, PageSize = pageSize, Usage = "HttpGet:~/api/Customers/{agentId}/{page?}/{pageSize?} or {args} can be on querystring, {args?} are optional" }; customerPagedListAPIResult.CustomerList = CustomerBusinessLayer.GetCustomersByAgentId(agentId, page, pageSize); if (customerPagedListAPIResult.CustomerList == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, customerPagedListAPIResult)); } return(Request.CreateResponse(HttpStatusCode.OK, customerPagedListAPIResult)); }
public void GetCustomerAsync_CustomerNotExistant_ReturnsNull() { CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer; // Random Guid, so we know it's (probably) not there. Guid id = Guid.NewGuid(); CustomerModel customerModelExpected = CustomerBusinessLayerTestFixture.CustomerModelWithId; CustomerModel customerModelResult = null; Func <Task> test = async() => { customerModelResult = await businessLayer.GetCustomerAsync(id); }; test.Should() .NotThrow(); customerModelResult.Should() .BeNull(); }
public void GetAllCustomersAsync_GetAllCustomers_GetsAllCustomersAsync() { CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer; IEnumerable <CustomerModel> customerModels = _fixture.CustomerModels; IEnumerable <CustomerModel> customerModelsResult = Enumerable.Empty <CustomerModel>(); Func <Task> test = async() => { customerModelsResult = await businessLayer.GetAllCustomersAsync(); }; test.Should() .NotThrow(); customerModelsResult.Should() .NotBeNullOrEmpty() .And .BeEquivalentTo(customerModels); }
void FillGrid() { #region Fill Customer List getBusiness = new CustomerBusinessLayer(); var list = getBusiness.GetAll(); List <Customer> passPaymentDateList = new List <Customer>(); List <Customer> _CustomerGridList = new List <Customer>(); foreach (var item in list) { if (item.PassPaymentDate < DateTime.Now) { passPaymentDateList.Add(item); } if (item.PassPaymentDate > DateTime.Now) { _CustomerGridList.Add(item); } } lblActiveCustomer.Text = list.Count().ToString(); lblPaymentCustomer.Text = _CustomerGridList.Count().ToString(); lblPassPaymentCustomer.Text = passPaymentDateList.Count().ToString(); #endregion #region FillDevCustomerGrid grdPaymentPassDate.DataSource = passPaymentDateList; grdAllCustomers.DataSource = _CustomerGridList; //grdPassPayDateMain.DataSource = passPaymentDateList; #endregion #region Fill Administration List getAdministrationBusiness = new AdministrationBusinessLayer(); var adminList = getAdministrationBusiness.GetAll(); grdAdministration.DataSource = adminList; #endregion }
public void GetCustomerAsync_GetExistingCustomer_GetsExistingCustomer() { CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer; Guid id = new Guid(CustomerBusinessLayerTestFixture.CustomerGuid); CustomerModel customerModelExpected = CustomerBusinessLayerTestFixture.CustomerModelWithId; CustomerModel customerModelResult = null; Func <Task> test = async() => { customerModelResult = await businessLayer.GetCustomerAsync(id); }; test.Should() .NotThrow(); customerModelResult.Should() .NotBeNull() .And .BeEquivalentTo(customerModelExpected); }
public void SearchCustomersAsync_CustomerExistsForSearchTerm_ReturnsEnumerableOfCustomerModels() { CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer; string searchTerm = CustomerBusinessLayerTestFixture.SearchTerm; IEnumerable <CustomerModel> customerModels = _fixture.CustomerModels; IEnumerable <CustomerModel> customerModelsResult = Enumerable.Empty <CustomerModel>(); Func <Task> test = async() => { customerModelsResult = await businessLayer.SearchCustomersAsync(searchTerm); }; test.Should() .NotThrow(); customerModelsResult.Should() .NotBeNullOrEmpty() .And .BeEquivalentTo(customerModels); }
private void Save(Customer model) { try { if (_id == 0) { getBusiness = new CustomerBusinessLayer(); getBusiness.Insert(model); } if (_id > 0) { getBusiness = new CustomerBusinessLayer(); getBusiness.Update(model); } FillGrid(); } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } }
private void gridView4_RowUpdated_1(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e) { var obj = e.Row as Customer; getBusiness = new CustomerBusinessLayer(); try { if (obj != null) { getBusiness.Update(obj); } } catch (Exception) { XtraMessageBox.Show("Güncelleme sırasında hata oluştu tekrar deneyiniz!"); } finally { FillGrid(); } }
// GET: Customer public ActionResult Index() { CustomerListViewModel cusListModel = new CustomerListViewModel(); CustomerBusinessLayer cusBL = new CustomerBusinessLayer(); var listCus = cusBL.GetCustomer(); var listCusVm = new List <CustomerViewModel>(); foreach (var item in listCus) { CustomerViewModel cusVmObj = new CustomerViewModel(); cusVmObj.CustomerName = item.CustomerName; cusVmObj.Address = item.Address; listCusVm.Add(cusVmObj); } cusListModel.CustomerViewList = listCusVm; string greeting; //获取当前时间 DateTime dt = DateTime.Now; //获取当前小时 int hour = dt.Hour; if (hour < 12) { greeting = "早上好"; } else { greeting = "中午好"; } cusListModel.Greeting = greeting; cusListModel.UserName = "******"; return(View(cusListModel)); }
public List <CustomerDto> GetAllCustomers() { CustomerBusinessLayer customerBll = new CustomerBusinessLayer(); return(customerBll.GetAllCustomers()); }
public void WillCallDBLayerOnceWhenCreate() { CustomerBusinessLayer.CreateCustomer(new Customer()); mockDBLayer.Verify(m => m.CreateEntity <Customer>(It.IsAny <Customer>()), Times.Once); }
public void WillCallDBLayerOnceWhenDelete() { CustomerBusinessLayer.DeleteCustomer(1); mockDBLayer.Verify(m => m.DeleteEntityByQuery <Customer>(It.IsAny <Query>()), Times.Once); }
public CustomersController(CustomerBusinessLayer customerBusinessLayer, ILogger <CustomersController> logger) { _customerBusinessLayer = customerBusinessLayer; _logger = logger; }