コード例 #1
0
        public IQueryable <Customer> SearchCustomers(CustomerOptions options)
        {
            if (options == null)
            {
                return(null);
            }

            var query = _context
                        .Set <Customer>()
                        .AsQueryable();

            if (!string.IsNullOrWhiteSpace(options.FirstName))
            {
                query = query.Where(c => c.FirstName == options.FirstName);
            }

            if (!string.IsNullOrWhiteSpace(options.VatNumber))
            {
                query = query.Where(c => c.VatNumber == options.VatNumber);
            }

            if (options != null)
            {
                query = query.Where(c => c.Id == options.CustomerId);
            }

            if (options.CreateFrom != null)
            {
                query = query.Where(c => c.Created >= options.CreateFrom);
            }

            query = query.Take(500);

            return(query);
        }
コード例 #2
0
        public Customer CreateCustomer(CustomerOptions options)
        {
            if (options == null)
            {
                return(null);
            }

            if (string.IsNullOrWhiteSpace(options.VatNumber))
            {
                return(null);
            }
            var customer = new Customer()
            {
                LastName  = options.LastName,
                FirstName = options.FirstName,
                VatNumber = options.VatNumber
            };

            _context.Add(customer);

            if (_context.SaveChanges() > 0)
            {
                return(customer);
            }

            return(null);
        }
コード例 #3
0
 private void ReloadEditor()
 {
     if (Transaction == null)
     {
         Name            = "New transaction";
         Description     = string.Empty;
         TransactionType = TransactionTypeOptions.FirstOrDefault();
         Customer        = CustomerOptions.FirstOrDefault();
         Date            = DateTime.Now;
         Value           = 0M;
     }
     else
     {
         Name            = Transaction.Name;
         Description     = Transaction.Description;
         TransactionType = TransactionTypeOptions.Where(tt => tt != null && tt.Id == Transaction.TransactionTypeId).FirstOrDefault();
         if (TransactionType == null)
         {
             TransactionType = TransactionTypeOptions.FirstOrDefault();
         }
         Customer = CustomerOptions.Where(c => c != null && c.Id == Transaction.CustomerId).FirstOrDefault();
         if (Customer == null)
         {
             Customer = CustomerOptions.FirstOrDefault();
         }
         Date  = Transaction.Date;
         Value = Transaction.Value;
     }
     isTransactionTypeBoxDirty = false;
 }
コード例 #4
0
        public void UpdateCustomer(CustomerOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException();
            }

            var existingCustomer = SearchCustomers
                                   (
                new CustomerOptions()
            {
                CustomerId = options.CustomerId
            }
                                   ).SingleOrDefault();

            if (existingCustomer == null)
            {
                throw new ArgumentNullException();
            }

            existingCustomer.IsActive  = options.IsActive;
            existingCustomer.FirstName = options.FirstName;
            existingCustomer.LastName  = options.LastName;
            existingCustomer.VatNumber = options.VatNumber;


            _context.SaveChanges();
        }
コード例 #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddFakeCustomers();

            var customerOptions = new CustomerOptions();

            Configuration.GetSection("CustomersModule").Bind(customerOptions);
            services.AddSingleton(customerOptions);

            services.Configure <CustomerOptions>(Configuration.GetSection("CustomersModule"));

            // services.Configure<CustomerOptions>(Configuration);

            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            //services.AddAuthentication("BasicAuthorization")
            //    .AddScheme<>

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
コード例 #6
0
        public OrderOption CreateOrder(CustomerOptions customerOpt)
        {
            if (customerOpt == null)
            {
                return(null);
            }
            Customer customer = dbContext.Customers.Find(customerOpt.Id);

            if (customer == null)
            {
                return(null);
            }
            Order order = new Order {
                Customer = customer
            };

            dbContext.Orders.Add(order);
            dbContext.SaveChanges();
            OrderOption orderOption = new OrderOption
            {
                CustomerName = customer.FirstName + " " + customer.LastName,
                Id           = order.Id
            };

            return(orderOption);
        }
コード例 #7
0
        public CustomerOptions CreateCustomer(CustomerOptions customerOptions)
        {
            Customer customer = new Customer  {
                FirstName   = customerOptions.FirstName,
                LastName    = customerOptions.LastName,
                Phone       = customerOptions.Phone,
                Email       = customerOptions.Email,
                VatNumber   = customerOptions.VatNumber,
                Address     = customerOptions.Address,
                Dob         = customerOptions.Dob,
                CreatedDate = DateTime.Now,
                IsActive    = true,
                TotalGross  = 0m
            };

            dbContext.Customers.Add(customer);
            dbContext.SaveChanges();
            return(new CustomerOptions
            {
                FirstName = customer.FirstName,
                LastName = customer.LastName,
                Phone = customer.Phone,
                Email = customer.Email,
                VatNumber = customer.VatNumber,
                Address = customer.Address,
                Dob = customer.Dob,
            });
        }
コード例 #8
0
        public async Task <IList <Certificate360> > QueryCustomer(CustomerOptions filter)
        {
            var statusTable = new DataTable();

            statusTable.Columns.Add("Val", typeof(int));

            if (filter.Status?.Any() ?? false)
            {
                foreach (var status in filter.Status)
                {
                    statusTable.Rows.Add(status);
                }
            }

            var param = new DynamicParameters();

            param.Add("@ID", filter.ID);
            param.Add("@Code", StringUtils.NullIfEmptyOrNull(filter.Code));
            param.Add("@GroupCode", StringUtils.NullIfEmptyOrNull(filter.GroupCode));
            param.Add("@Name", StringUtils.NullIfEmptyOrNull(filter.Name));
            param.Add("@CertificateNo", StringUtils.NullIfEmptyOrNull(filter.CertificateNo));
            param.Add("@Premise", StringUtils.NullIfEmptyOrNull(filter.Premise));
            param.Add("@PremiseID", filter.PremiseID);
            param.Add("@Status", statusTable.AsTableValuedParameter("dbo.SmallIntType"));

            var mapper = new Certificate360Mapper();

            return((await SqlMapper.QueryAsync(
                        _unitOfWork.Connection,
                        "SelectCustomer",
                        new[]
            {
                typeof(Certificate360),
                typeof(Customer),
                typeof(Code),
                typeof(Code),
                typeof(Premise),
                typeof(Officer)
            },
                        obj =>
            {
                var cert = obj[0] as Certificate360;
                var certCustomer = obj[1] as Customer;
                var certCustCode = obj[2] as Code;
                var certCustGroupCode = obj[3] as Code;
                var certPremise = obj[4] as Premise;
                var certCustOfficer = obj[5] as Officer;
                return mapper.Map(cert,
                                  certCustomer,
                                  certCustCode,
                                  certCustGroupCode,
                                  certCustOfficer,
                                  certPremise);
            },
                        param,
                        splitOn: "ID, CustID, CustCodeID, CustCodeGroupID, PremID, OfficerID",
                        commandType: CommandType.StoredProcedure,
                        transaction: _unitOfWork.Transaction)).ToList());
        }
コード例 #9
0
        public CustomerOptions AddCustomer(CustomerOptions customerOpt)
        {
            ICustomerService customerService = new CustomerService();
            CustomerOptions  customerOptions = customerService.CreateCustomer(customerOpt);


            return(customerOptions);
        }
コード例 #10
0
ファイル: HomeController.cs プロジェクト: illarios/Ms-App-Crm
        public IActionResult UpdateCustomerWithDetails([FromRoute] int id)
        {
            CustomerOptions     customerOptions = customerService.GetCustomerById(id);
            CustomerOptionModel model           = new CustomerOptionModel {
                customer = customerOptions
            };

            return(View(model));
        }
コード例 #11
0
 private static void customerOptToCustomer(CustomerOptions customerOpt, Customer customer)
 {
     customer.FirstName = customerOpt.FirstName;
     customer.LastName  = customerOpt.LastName;
     customer.Dob       = customerOpt.Dob;
     customer.VatNumber = customerOpt.VatNumber;
     customer.Address   = customerOpt.Address;
     customer.Email     = customerOpt.Email;
 }
コード例 #12
0
        public Customer GetCustomerById(int opt)
        {
            var po = new CustomerOptions();

            po.CustomerId = opt;
            var customer = SearchCustomers(po).SingleOrDefault();

            return(customer);
        }
コード例 #13
0
        public Customer UpdateCustomer(CustomerOptions customerOpt, int id)
        {
            Customer customer = dbContext.Customers.Find(id);

            customer.Address = customerOpt.Address;
            customer.Email   = customerOpt.Email;
            dbContext.SaveChanges();

            return(customer);
        }
コード例 #14
0
        public IActionResult CreateCustomer(CustomerOptions options)
        {
            if (options == null)
            {
                return(BadRequest());
            }

            var customer = _customerService.CreateCustomer(options);

            _dbContext.Add(customer);

            _dbContext.SaveChanges();

            return(Json(customer));
        }
コード例 #15
0
        static void Main(string[] args)
        {
            CustomerOptions customer = new CustomerOptions()
            {
                FirstName = "Anna", LastName = "Karenina"
            };
            ICustomerService customerService = new CustomerService();

            customerService.CreateCustomer(customer);

            CustomerOptions customer2 = new CustomerOptions()
            {
                FirstName = "Darya", LastName = "Alexandrova"
            };

            customerService.CreateCustomer(customer2);
        }
コード例 #16
0
        public IActionResult SearchCustomers(CustomerOptions options)
        {
            if (options == null)
            {
                return(null);
            }

            var customerList = _customerService
                               .SearchCustomers(options)
                               .ToList();

            if (customerList == null)
            {
                return(NotFound());
            }

            return(Json(customerList));
        }
コード例 #17
0
        public CustomerOptions UpdateCustomer(CustomerOptions customerOpt, int id)
        {
            Customer customer = dbContext.Customers.Find(id);

            customerOptToCustomer(customerOpt, customer);
            dbContext.SaveChanges();

            return(new CustomerOptions
            {
                FirstName = customer.FirstName,
                LastName = customer.LastName,
                Phone = customer.Phone,
                Email = customer.Email,
                VatNumber = customer.VatNumber,
                Address = customer.Address,
                Dob = customer.Dob,
            });
        }
コード例 #18
0
        public static IQueryable <Customer> SearchCustomers(CustomerOptions customerOptions, TinyCrmDbContext dbContext)
        {
            if (customerOptions.CreatedFrom != null &&
                customerOptions.CreatedTo != null &&
                customerOptions.CreatedFrom > customerOptions.CreatedTo)
            {
                return(null);
            }

            var query = dbContext.Set <Customer>().AsQueryable();

            if (customerOptions.CustomerId != null)
            {
                query = query.Where(c => c.CustomerId == customerOptions.CustomerId);
            }

            if (customerOptions.VatNumber != null)
            {
                query = query.Where(c => c.VatNumber == customerOptions.VatNumber);
            }

            if (customerOptions.CreatedFrom != null)
            {
                query = query.Where(c => c.Created >= customerOptions.CreatedFrom);
            }

            if (customerOptions.CreatedTo != null)
            {
                query = query.Where(c => c.Created <= customerOptions.CreatedTo);
            }

            if (!String.IsNullOrWhiteSpace(customerOptions.FirstName))
            {
                query = query.Where(c => c.FirstName.Contains(customerOptions.FirstName));
            }

            if (!String.IsNullOrWhiteSpace(customerOptions.LastName))
            {
                query = query.Where(c => c.LastName.Contains(customerOptions.LastName));
            }

            query = query.Take(500);
            return(query);
        }
コード例 #19
0
        public IQueryable <Customer> SearchCustomers(CustomerOptions opt)   // search function
        {
            //string optCustomerId = Convert.ToString(opt.CustomerId);
            //string optCustomerDateFrom = Convert.ToString(opt.CreatedFrom);
            //string optCustomerDateTo = Convert.ToString(opt.CreatedTo);

            if (opt.CustomerId != null)  // ean exei dosei id o xrhsths sto UI tha epistrepsei to monadiko record
            {
                var queryId = db_
                              .Set <Customer>()
                              .AsQueryable();

                queryId = queryId.Where(c => c.CustomerId == opt.CustomerId);
                //Console.WriteLine($"id pelati einai {opt.CustomerId}");

                return(queryId);
            }
            else
            {
                var query = db_
                            .Set <Customer>()
                            .AsQueryable();

                if (!String.IsNullOrWhiteSpace(opt.LastName))
                {
                    query = query.Where(c => c.LastName == opt.LastName);
                }
                if (!String.IsNullOrWhiteSpace(opt.FirstName))
                {
                    query = query.Where(c => c.FirstName == opt.FirstName);
                }
                if (!String.IsNullOrWhiteSpace(opt.VatNumber))
                {
                    query = query.Where(c => c.VatNumber == opt.VatNumber);
                }
                // if (!String.IsNullOrWhiteSpace(opt.CreatedFrom) && !String.IsNullOrWhiteSpace(optCustomerDateTo))
                //{
                //   query = query.Where(c => c.Created >= opt.CreatedFrom && c.Created <= opt.CreatedTo);
                // }
                query.Take(500);
                return(query);
            }
        }
コード例 #20
0
        protected async override void OnLoad(object param)
        {
            AllowInput = false;

            try
            {
                IDatabaseService dbconn = new DatabaseService();
                dbconn.ConnectionString = ConnectionStringsProvider.Get();

                TransactionTypeOptions = await dbconn.TransactionTypeService.GetTransactionTypesAsync();

                CustomerOptions = await dbconn.CustomerService.GetCustomersAsync();

                var transactionsRaw = await dbconn.TransactionService.GetTransactionsAsync();

                Transactions = new ObservableCollection <ITransaction>(transactionsRaw);

                ReloadEditor();

                RaisePropertyChanged("TransactionTypeOptions");
                RaisePropertyChanged("CustomerOptions");

                TransactionType       = TransactionTypeOptions.FirstOrDefault();
                FilterTransactionType = TransactionTypeOptions.FirstOrDefault();
                Customer       = CustomerOptions.FirstOrDefault();
                FilterCustomer = CustomerOptions.FirstOrDefault();

                base.OnLoad(param);
            }
            catch (SqlException e)
            {
                MessageBox.Show("Unexpected SQL error occurred while accessing database. Details:/n" + e.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (Exception)
            {
                MessageBox.Show("Unexpected error occurred while accessing database", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                AllowInput = true;
            }
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: gstamata/ModelCRM
        static void Main(string[] args)
        {
            CustomerOptions custOpt = new CustomerOptions
            {
                FirstName = "Mema",
                LastName  = "Stamataki",
                Address   = "Kallithea",
                VatNumber = "123456789",
                Email     = "*****@*****.**",
                Phone     = "6951915214",
                Dob       = new DateTime(1993, 7, 6),
            };
            CustomerCrud custCrud = new CustomerCrud();
            Customer     customer = custCrud.CreateCustomer(custOpt);

            Console.WriteLine($"Id = { customer.Id}" + $"FirstName = { customer.FirstName}");

            Customer toFind = custCrud.GetCustomerById(1);

            Console.WriteLine($"Id = { toFind.Id}" + $"FirstName = { toFind.FirstName}");
        }
コード例 #22
0
        protected async override void OnLoad(object param)
        {
            AllowInput = false;

            try
            {
                //BcDrawer = bcdFactory.CreateForTransactions(param as Grid);
                ReloadTimeStepOptions();
                TimeStep = CurrentTimeStepOptions.FirstOrDefault();

                IDatabaseService dbconn = new DatabaseService();
                dbconn.ConnectionString = ConnectionStringsProvider.Get();

                CustomerOptions = await dbconn.CustomerService.GetCustomersAsync();

                data = await dbconn.TransactionService.GetTransactionsAsync();

                RaisePropertyChanged("CustomerOptions");

                FilterCustomer = CustomerOptions.FirstOrDefault();
                IsIncome       = false;

                ReloadBarChart();
                ReloadPieChart();

                base.OnLoad(param);
            }
            catch (SqlException e)
            {
                MessageBox.Show("Unexpected SQL error occurred while accessing database. Details:/n" + e.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (Exception)
            {
                MessageBox.Show("Unexpected error occurred while accessing database", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                AllowInput = true;
            }
        }
コード例 #23
0
ファイル: CustomerCrud.cs プロジェクト: gstamata/ModelCRM
        public Customer CreateCustomer(CustomerOptions customerOptions)
        {
            Customer customer = new Customer {
                Address    = customerOptions.Address,
                CreateDate = DateTime.Now,
                Dob        = customerOptions.Dob,
                Email      = customerOptions.Email,
                FirstName  = customerOptions.FirstName,
                IsActive   = true,
                LastName   = customerOptions.LastName,
                Phone      = customerOptions.Phone,
                TotalGross = 0M,
                VatNumber  = customerOptions.VatNumber,
            };

            using CrmAppDbContext dbContext = new CrmAppDbContext();
            dbContext.Customers.Add(customer);
            dbContext.SaveChanges();


            return(customer);
        }
コード例 #24
0
ファイル: Program.cs プロジェクト: orestistsioukis/ModelCrm
        static void Main(string[] args)
        {
            CustomerOptions custOpt = new CustomerOptions
            {
                FirstName = "Dimitris",
                LastName  = "Dimitriou",
                Address   = "Athens",
                VatNumber = "012345678",
                Email     = "*****@*****.**",
                Phone     = "210-74 000 111",
                Dob       = new DateTime(1970, 12, 31),
            };

            CustomerCrud custCrud = new CustomerCrud();

            Customer customer = custCrud.CreateCustomer(custOpt);

            //Console.WriteLine("Id = "
            //    + customer.Id
            //    + " FirstName= "
            //    + customer.FirstName);


            Console.WriteLine($"Id = {customer.Id} " +
                              $"FirstName= {customer.FirstName}");

            Customer toFind = custCrud.GetCustomerById(1);

            Console.WriteLine($"Id = {toFind.Id} " +
                              $"FirstName= {toFind.FirstName}");

            toFind = custCrud.GetCustomerById(100);
            if (toFind != null)
            {
                Console.WriteLine($"Id = {toFind.Id} " +
                                  $"FirstName= {toFind.FirstName}");
            }
        }
コード例 #25
0
        public IActionResult Update([FromBody] CustomerOptions options)
        {
            var customer = _customerService.SearchCustomerById(options.CustomerId);

            if (customer == null)
            {
                return(BadRequest());
            }

            //var customer = _customerService.SearchCustomerById(id);

            //if (customer == null)
            //{
            //    return BadRequest();
            //}

            _customerService.UpdateCustomer(options);

            _dbContext.SaveChanges();


            return(Json(customer));
        }
コード例 #26
0
        public CustomerOptions AddCustomer([FromForm] CustomerWithFileModel customerOptWithFileModel)
        {
            if (customerOptWithFileModel == null)
            {
                return(null);
            }
            var formFile = customerOptWithFileModel.Picture;

            var filename = customerOptWithFileModel.Picture.FileName;

            if (formFile.Length > 0)
            {
                var filePath = Path.Combine(hostingEnvironment.WebRootPath, "uploadedimages", filename);


                using (var stream = System.IO.File.Create(filePath))
                {
                    formFile.CopyTo(stream);
                }
            }

            CustomerOptions customerOpt = new CustomerOptions {
                FirstName = customerOptWithFileModel.FirstName,
                LastName  = customerOptWithFileModel.LastName,
                Address   = customerOptWithFileModel.Address,
                Dob       = customerOptWithFileModel.Dob, Email = customerOptWithFileModel.Email,
                Phone     = customerOptWithFileModel.Phone, VatNumber = customerOptWithFileModel.VatNumber
            };

            /// we save the picture path in the Phone field
            customerOpt.Phone = filename;

            CustomerOptions customerOptions = customerService.CreateCustomer(customerOpt);

            return(customerOptions);
        }
コード例 #27
0
 public SelectCustomerCommand(CustomerOptions filter)
 {
     _filter = filter;
 }
コード例 #28
0
ファイル: CustomerService.cs プロジェクト: israelsam/Qantler
 public async Task <IList <Certificate360> > QueryCustomer(CustomerOptions filter)
 {
     return(await Execute(new SelectCustomerCommand(filter)));
 }
コード例 #29
0
 public Customer UpdateCustomer(CustomerOptions customerOpt, int id)
 {
     return(customerService.UpdateCustomer(customerOpt, id));
 }
コード例 #30
0
 public Customer AddCustomer(CustomerOptions customerOpt)
 {
     return(customerService.CreateCustomer(customerOpt));
 }