コード例 #1
0
        private List <Customer> fillCustomerList()
        {
            CustomerBusiness _CustomerBusiness = new CustomerBusiness();
            CustomerList     _CustomerList     = _CustomerBusiness.SelectRows(null, null, null, null, null);

            return(_CustomerList);
        }
コード例 #2
0
        private void FormControlsLoad()
        {
            _pBuss = new ProjectBusiness(_user);
            if (_projectId > 0)
            {
                try
                {
                    _project = _pBuss.Get(_projectId);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                txtName.Text       = _project.Name;
                dtpEndDate.Value   = _project.EndDate;
                dtpStartDate.Value = _project.StartDate;
            }

            CustomerBusiness custBuss = new CustomerBusiness(_user);

            cmbCustomer.DataSource    = null;
            cmbCustomer.DataSource    = custBuss.GetAll();
            cmbCustomer.DisplayMember = "CompanyName";
            cmbCustomer.ValueMember   = "ID";
            if (_projectId > 0)
            {
                cmbCustomer.SelectedValue = _project.Customer.ID;
            }
        }
コード例 #3
0
ファイル: CustomerController.cs プロジェクト: thuyenvinh/qlvx
        public ActionResult listCustomer(int?page)
        {
            var customer   = CustomerBusiness.SearchCustomerByText(String.Empty);
            int pageNumber = (page ?? 1);

            return(PartialView("listCustomer", customer.ToPagedList(pageNumber, 3)));
        }
コード例 #4
0
ファイル: AccountController.cs プロジェクト: gizmotic/Estudos
        public ActionResult Create(Customer usuario)
        {
            var customer = CustomerBusiness.Common.SelectSingle
                               (w => w.Email.Equals(usuario.Email)
                               );
            Dictionary <string, string> allErrors = new Dictionary <string, string>();

            if (customer == null)
            {
                CustomerBusiness.Insert(usuario);
            }
            else
            {
                allErrors.Add(
                    "user-exists",
                    "Já existe um usuário cadastrado com o mesmo e-mail fornecido."
                    );
            }

            if (allErrors != null && allErrors.Count > 0)
            {
                foreach (var error in allErrors)
                {
                    this.ModelState.AddModelError(
                        error.Key,
                        error.Value
                        );
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #5
0
        private void CustomerListForm_Load(object sender, EventArgs e)
        {
            _customerBusiness = new CustomerBusiness();
            List <Customer> customerList = _customerBusiness.GetAll();

            dgvCustomerList.DataSource = customerList;
        }
コード例 #6
0
        public IActionResult AddCustomer1([FromBody] CustomerDTO customer)
        {
            try
            {
                var customerService = new CustomerBusiness(unitOfWork);
                var addedCustomer   = customerService.AddCustomer1(customer);

                return(Ok(new RequestResult()
                {
                    IsSucceeded = true,
                    Result = addedCustomer,
                    Message = "Customer successfully added"
                }));
            }
            catch (InvalidObjectException exception)
            {
                return(BadRequest(new RequestResult()
                {
                    IsSucceeded = false,
                    Result = exception.InvalidObject,
                    Message = $"Could not add '{exception.ObjectName}'.",
                    ErrorMessages = exception.ErrorMessages
                }));
            }
            catch (Exception exception)
            {
                return(BadRequest(new RequestResult()
                {
                    IsSucceeded = false,
                    Result = customer,
                    Message = exception.Message
                }));
            }
        }
コード例 #7
0
        public ICollection <CustomerDTO> GetCustomersFromDB()
        {
            ICollection <CustomerDTO> outputList = default(ICollection <CustomerDTO>);

            try
            {
                // 1- Select All Customers From DB
                CustomerBusiness _CustomerBusiness = new CustomerBusiness();
                CustomerList     _CustomerList     = _CustomerBusiness.SelectRows(null, null, null, null, null);

                if (_CustomerList != null && _CustomerList.Count > 0)
                //outputList = Mapper.MapUserAsOutput();
                {
                    // 2- Prepare Mapping Objects (Fill Values from DB)
                    Mapper._CustomerList  = fillCustomerList(); //default(List<Customer>);
                    Mapper._WorkFieldList = fillWorkFieldList();

                    // 3- Perform Mapping to Output
                    outputList = Mapper.MapCustomerAsOutput();
                }
            }
            catch (Exception ex)
            {
                // Log Exception Here
                throw; //new Exception(ex.Message);
            }

            return(outputList);
        }
コード例 #8
0
ファイル: CampaignController.cs プロジェクト: dsamueza/Engine
 public CampaignController(
     UserManager <ApplicationUser> userManager,
     IHttpContextAccessor httpContextAccessor,
     MardisContext mardisContext,
     ILogger <CampaignController> logger,
     ILogger <ServicesFilterController> loggeFilter,
     IDataProtectionProvider protectorProvider,
     IMemoryCache memoryCache,
     IHostingEnvironment hostingEnvironment,
     RedisCache distributedCache) :
     base(userManager, httpContextAccessor, mardisContext, logger)
 {
     Protector                         = protectorProvider.CreateProtector(GetType().FullName);
     _campaignBusiness                 = new CampaignBusiness(mardisContext);
     TableName                         = CCampaign.TableName;
     ControllerName                    = CCampaign.Controller;
     _taskCampaignBusiness             = new TaskCampaignBusiness(mardisContext, distributedCache);
     _commonBusiness                   = new CommonBusiness(mardisContext);
     _customerBusiness                 = new CustomerBusiness(mardisContext);
     _statusCampaignBusiness           = new StatusCampaignBusiness(mardisContext, memoryCache);
     _userBusiness                     = new UserBusiness(mardisContext);
     _channelBusiness                  = new ChannelBusiness(mardisContext);
     _serviceBusiness                  = new ServiceBusiness(mardisContext, distributedCache);
     _statusTaskBusiness               = new StatusTaskBusiness(mardisContext, distributedCache);
     _taskNotImplementedReasonBusiness = new TaskNotImplementedReasonBusiness(mardisContext);
     _hostingEnv                       = hostingEnvironment;
     _profileBusiness                  = new ProfileBusiness(mardisContext);
     if (ApplicationUserCurrent.UserId != null)
     {
         _userId   = new Guid(ApplicationUserCurrent.UserId);
         _Profile  = ApplicationUserCurrent.ProfileId;
         _typeuser = _profileBusiness.GetById(_Profile).IdTypeUser;
     }
 }
コード例 #9
0
        public ActionResult _ListCustomer()
        {
            var db     = new CustomerBusiness();
            int minRow = 0;
            int maxRow = 0;

            int.TryParse(HttpContext.Request["start"], out minRow);
            int length = 10;

            int.TryParse(HttpContext.Request["length"], out length);
            maxRow = (minRow + length);
            int draw = 0;

            int.TryParse(HttpContext.Request["draw"], out draw);
            string search      = HttpContext.Request["search[value]"].Trim();
            int    currentPage = (minRow / 10) + 1;
            int    roleid      = user.Roleid;
            int    idcenter    = user.BranchId;
            var    result      = db.ListCustomer(search, currentPage, 10, idcenter, roleid);

            return(Content(JsonConvert.SerializeObject(new
            {
                data = result.Data,
                draw = draw,
                recordsFiltered = result.Total,
                recordsTotal = result.Total
            })));
        }
コード例 #10
0
        public void SortCustomersByBothNamesAcending()
        {
            var data = new List <Customer>
            {
                new Customer {
                    FirstName = "CustomerB", LastName = "A"
                },
                new Customer {
                    FirstName = "CustomerA", LastName = "C"
                },
                new Customer {
                    FirstName = "CustomerB", LastName = "B"
                },
            }.AsQueryable();

            var mockSet = new Mock <DbSet <Customer> >();

            mockSet.As <IQueryable <Customer> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <Customer> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <Customer> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <Customer> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var mockContext = new Mock <CarDealershipContext>();

            mockContext.Setup(m => m.Customers).Returns(mockSet.Object);

            var service        = new CustomerBusiness(mockContext.Object);
            var customersFound = service.SortCustomerByBothNamesAscending();

            Assert.AreEqual(3, customersFound.Count());
            Assert.AreEqual("CustomerA", customersFound[0].FirstName);
            Assert.AreEqual("CustomerB", customersFound[1].FirstName);
            Assert.AreEqual("CustomerB", customersFound[2].FirstName);
            Assert.AreEqual("B", customersFound[2].LastName);
        }
コード例 #11
0
        public void SetUp()
        {
            _customerRepositoryMock = new Mock <ICustomerRepository>();

            _customerBusiness = new CustomerBusiness(
                _customerRepositoryMock.Object);
        }
コード例 #12
0
ファイル: CustomerController.cs プロジェクト: thuyenvinh/qlvx
        //
        // GET: /Customer/

        public ActionResult Index(int?page)
        {
            int pageNumber = (page ?? 1);
            var customer   = CustomerBusiness.SearchCustomerByText(String.Empty);

            return(View(customer.ToPagedList(pageNumber, 3)));
        }
コード例 #13
0
        public void GetCustomersByFirstName()
        {
            var data = new List <Customer>
            {
                new Customer {
                    FirstName = "Customer1"
                },
                new Customer {
                    FirstName = "Customer1"
                },
                new Customer {
                    FirstName = "Customer3"
                },
            }.AsQueryable();

            var mockSet = new Mock <DbSet <Customer> >();

            mockSet.As <IQueryable <Customer> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <Customer> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <Customer> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <Customer> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var mockContext = new Mock <CarDealershipContext>();

            mockContext.Setup(m => m.Customers).Returns(mockSet.Object);

            var service        = new CustomerBusiness(mockContext.Object);
            var customersFound = service.GetCustomersByFirstName("Customer1");

            Assert.AreEqual(2, customersFound.Count());
            Assert.AreEqual("Customer1", customersFound[0].FirstName);
            Assert.AreEqual("Customer1", customersFound[1].FirstName);
        }
コード例 #14
0
        public HttpResponseMessage FindCustomer(int id)
        {
            try
            {
                CustomerBusiness repo = new CustomerBusiness();
                var result            = repo.FindCustomerByIdentificatonNumber(id);

                Customers tempData = new Customers()
                {
                    DatetimeOfCreated = result.DatetimeOfCreated,
                    Name                         = result.Name,
                    Address                      = result.Address,
                    Surname                      = result.Surname,
                    CityOfBirth                  = result.CityOfBirth,
                    IdentificationNumber         = result.IdentificationNumber,
                    BeginningDateOfDriverLicense = result.BeginningDateOfDriverLicense,
                    EndingDateOfDriverLicense    = result.EndingDateOfDriverLicense,
                    Id = result.Id
                };

                return(Request.CreateResponse(HttpStatusCode.OK, tempData));
            }
            catch (Exception ex)
            {
                LogHelper.Log(LogTarget.File,
                              "Find Customer failed. " + id + "\n" + ExceptionHelper.ExceptionToString(ex));
                return(null);
            }
        }
コード例 #15
0
ファイル: AccountController.cs プロジェクト: gizmotic/Estudos
        public ActionResult Login(Customer usuario)
        {
            if (usuario != null && !string.IsNullOrEmpty(usuario.Email) && !string.IsNullOrEmpty(usuario.Password))
            {
                var loggedUSer = CustomerBusiness.LoginCheck(usuario.Email, usuario.Password);
                if (loggedUSer != null)
                {
                    Session["loggedUSer"] = loggedUSer;
                    return(RedirectToAction("FirstPage", "Home"));
                }
                else
                {
                    return(RedirectToAction("Index", "Account"));
                }
            }
            else
            {
                this.ModelState.AddModelError(
                    "invalid-user",
                    "Usuário ou senha inválidos."
                    );
            }

            return(RedirectToAction("Index", "Account"));
        }
コード例 #16
0
ファイル: Form1.cs プロジェクト: Berkaybadur/BerkayBadur
 private void BtnDelete_Click(object sender, EventArgs e)
 {
     customer.CustomerId = Convert.ToInt16(txtCustomerId.Text);
     customerBusiness    = new CustomerBusiness(customer);
     classBusiness.Operation(customerBusiness, ClassBusiness.OperationType.Delete);
     List();
 }
コード例 #17
0
        public CustomerDTO UpdateCustomerinDB(CustomerDTO customerDTO)
        {
            BaseDataAccess _db = new BaseDataAccess();

            using (DbTransaction dbTransaction = _db.CreateTransaction())
            {
                try

                {
                    // 1- Perform Mapping to  Input (for Saving in DB)
                    if (Mapper.MapCustomerAsInput(customerDTO))
                    {
                        // 2- Select Customer to be updated
                        CustomerBusiness customerBusiness = new CustomerBusiness();
                        CustomerList     customerList     = customerBusiness.SelectRows(Mapper._Customer.Id, null, null, null, null);

                        if (customerList != null && customerList.Count > 0)
                        {
                            customerList[0].code        = Mapper._Customer.code;
                            customerList[0].name        = Mapper._Customer.name;
                            customerList[0].nameAr      = Mapper._Customer.nameAr;
                            customerList[0].address     = Mapper._Customer.address;
                            customerList[0].phone       = Mapper._Customer.phone;
                            customerList[0].email       = Mapper._Customer.email;
                            customerList[0].workFieldId = Mapper._Customer.workFieldId;

                            // 3- Update Customer Data by Input Values
                            customerBusiness = new CustomerBusiness();
                            if (customerBusiness.UpdateRow(dbTransaction, customerList[0]) > 0)
                            {
                                dbTransaction.Commit();
                            }

                            else
                            {
                                dbTransaction.Rollback();
                                throw new Exception("DataBase Operation Failure");
                            }
                        }
                        else
                        {
                            dbTransaction.Rollback();
                            throw new Exception("Customer Id Not Found in DB");
                        }
                    }
                    else
                    {
                        throw new ArgumentNullException("customerDTO");
                    }
                }
                catch (Exception ex)
                {
                    dbTransaction.Rollback();
                    throw;
                }
            }

            return(customerDTO);
        }
コード例 #18
0
        /// <summary>
        /// Populate the data grid with information about customers with given first name
        /// </summary>
        private void PopulateDataGridViewGetCustomersByFirstName()
        {
            dataGridView.Rows.Clear();
            CustomerBusiness customerBusiness = new CustomerBusiness();
            var customersList = customerBusiness.GetCustomersByFirstName(txtGet.Text);

            DataPopulator(customersList);
        }
コード例 #19
0
        public ActionResult EditCustomer(int id)
        {
            var db     = new CustomerBusiness();
            var result = db.GetCustomerById(id);

            ViewBag.id = id;
            return(PartialView(result));
        }
コード例 #20
0
        public CustomerBusinessTests()
        {
            _databaseProviderMock        = new Mock <IDatabaseProvider>();
            _customerValidatorMock       = new Mock <ICustomerInformationValidatior>();
            _officialIdValidatorProvider = new Mock <IHRSystemProvider>();

            _sut = new CustomerBusiness(_databaseProviderMock.Object, _customerValidatorMock.Object, _officialIdValidatorProvider.Object);
        }
コード例 #21
0
        private void CustomerEditForm_Load(object sender, EventArgs e)
        {
            RefreshCustomerEmployee();
            MainForm mainform = (MainForm)this.MdiParent;

            _user   = mainform.GetUser();
            _cusBLL = new CustomerBusiness(_user);
        }
コード例 #22
0
        // GET: Customer
        public ActionResult Index()
        {
            CustomerBusiness customerBusiness = new CustomerBusiness();

            List <Customer> lstCustomer = customerBusiness.LayDanhSachCustomer();

            return(View(lstCustomer));
        }
コード例 #23
0
        /// <summary>
        /// Populate the data grid with information sorted by customers' town name in descending order
        /// </summary>
        private void PopulateDataGridViewSortCustomerByTownNameDescending()
        {
            dataGridView.Rows.Clear();
            CustomerBusiness customerBusiness = new CustomerBusiness();
            var customersList = customerBusiness.SortCustomersByTownNameDescending();

            DataPopulator(customersList);
        }
コード例 #24
0
        //Main logic//
        //Get logic//

        /// <summary>
        /// Populate the data grid with information about all existing customers in the database
        /// </summary>
        private void PopulateDataGridViewDefault()
        {
            dataGridView.Rows.Clear();
            CustomerBusiness customerBusiness = new CustomerBusiness();
            var customersList = customerBusiness.GetAllCustomers();

            DataPopulator(customersList);
        }
コード例 #25
0
ファイル: CustomerController.cs プロジェクト: thuyenvinh/qlvx
        public ActionResult Create(Customer cs, FormCollection collection)
        {
            IFormatProvider iFP = new System.Globalization.CultureInfo("vi-VN", true);

            cs.CreateDate = DateTime.Parse(collection["CreateDate"], iFP);
            var result = CustomerBusiness.Insert(cs);

            return(PartialView(cs));
        }
コード例 #26
0
        /// <summary>
        /// Update the input text boxes with information for a selected customer
        /// </summary>
        /// <param name="Id">The ID of a selected customer</param>
        private void UpdateTextBoxes(int Id)
        {
            CustomerBusiness customerBusiness = new CustomerBusiness();
            Customer         customer         = customerBusiness.GetCustomerById(Id);

            txtFirstName.Text = customer.FirstName;
            txtLastName.Text  = customer.LastName;
            txtTown.Text      = customer.TownId.ToString();
        }
コード例 #27
0
ファイル: CustomerController.cs プロジェクト: thuyenvinh/qlvx
        public ActionResult Edit(Customer cs, FormCollection collection)
        {
            //Business.DbConnect.Customer cs = new Customer();
            IFormatProvider iFP = new System.Globalization.CultureInfo("vi-VN", true);

            cs.CreateDate = DateTime.Parse(collection["CreateDate"], iFP);
            var result = CustomerBusiness.Update(cs);

            return(PartialView(cs));
        }
コード例 #28
0
        /// <summary>
        /// Populate the data grid with information about customers with given town Id
        /// </summary>
        private void PopulateDataGridViewGetCustomerByTownId()
        {
            dataGridView.Rows.Clear();
            CustomerBusiness customerBusiness = new CustomerBusiness();

            int.TryParse(txtGet.Text, out int townId);
            var customersList = customerBusiness.GetCustomersByTownId(townId);

            DataPopulator(customersList);
        }
コード例 #29
0
        /// <summary>
        /// Populate the data grid with information about customer with given customer Id
        /// </summary>
        private void PopulateDataGridViewGetCustomerById()
        {
            dataGridView.Rows.Clear();
            CustomerBusiness customerBusiness = new CustomerBusiness();

            int.TryParse(txtGet.Text, out int customerId);
            var customer = customerBusiness.GetCustomerById(customerId);

            DataPopulatorSingle(customer);
        }
コード例 #30
0
ファイル: CustomerPresenter.cs プロジェクト: rizonemeer/PoS
        public CustomerPresenter(ICustomerView view)
        {
            _businessOrder = new ReportBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Order> >());
            _business      = new CustomerBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Customer> >());
            _view          = view;

            Customer Customer = new Customer();

            _model = new CustomerModel(new Customer());
            _view.InitView(_model);
        }
コード例 #31
0
        public Response<Model.Customer> CreateCustomer(Model.Customer customer)
        {
            Response<Customer> response = null;
            CustomerBusiness customerBusiness = null;

            try
            {
                customerBusiness = new CustomerBusiness();
                return customerBusiness.Create(customer);
            }
            catch (Exception ex)
            {
                response = new Response<Customer>(null, ResponseStatus.Error, ex.Message);
            }

            return response;
        }