Beispiel #1
0
        public IEnumerable <CommissionDto> GetCommissions()
        {
            try
            {
                List <Commission>    commissions  = new List <Commission>();
                List <CommissionDto> commisionDto = new List <CommissionDto>();
                List <Member>        members      = new List <Member>();
                CommissionDto        commis;
                Address address = new Address();

                commissions = _context.Commission.ToList();
                members     = _context.Member.Include("user").ToList();

                foreach (Commission co in commissions)
                {
                    commis = new CommissionDto(co.Id, co.code, co.libelle);
                    foreach (Member member in members)
                    {
                        if (co.Id == member.commissionId)
                        {
                            commis.members.Add(new User(member.user.firstName, member.user.lastName, member.user.date, member.user.mail, member.user.numberTel, member.user.password, member.user.type, address));
                        }
                    }
                    commisionDto.Add(commis);
                }

                return(commisionDto);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message + e.StackTrace);
                throw;
            }
        }
 /// <summary>
 /// 转换为佣金实体
 /// </summary>
 /// <param name="dto">佣金数据传输对象</param>
 public static Commission ToEntity(this CommissionDto dto)
 {
     if (dto == null)
     {
         return(new Commission());
     }
     return(dto.MapTo(new Commission(dto.Id.ToGuid())));
 }
Beispiel #3
0
        public async Task CreateCurrency(string name, CommissionDto dto)
        {
            var currency = new CurrencyRecord {
                Name = name
            };
            await _context.Currencies.AddAsync(currency);

            await _context.SaveChangesAsync();

            var deposit    = CommissionManager.CreateCommission(currency.Id, dto, OperationType.Deposit);
            var transfer   = CommissionManager.CreateCommission(currency.Id, dto, OperationType.Transfer);
            var withdrawal = CommissionManager.CreateCommission(currency.Id, dto, OperationType.Withdrawal);

            await _context.Commissions.AddRangeAsync(deposit, transfer, withdrawal);

            await _context.SaveChangesAsync();
        }
Beispiel #4
0
        public bool addCommission(CommissionDto commission)
        {
            try
            {
                Commission newCommission = new Commission(commission.code, commission.libelle);
                Console.WriteLine(newCommission);

                foreach (User member in commission.members)
                {
                    _context.User.Find(member.Id).member.Add(new Member(newCommission, member));
                }

                _context.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message + e.StackTrace);
                throw;
            }
        }
Beispiel #5
0
        public static CommissionRecord CreateCommission(int currencyId, CommissionDto commissionDto,
                                                        OperationType type, string userId = null)
        {
            var commission = new CommissionRecord
            {
                CurrencyId = currencyId, Type = commissionDto.Type, OperationType = type,
                MaxValue   = commissionDto.MaxOperationValue, UserId = userId
            };

            if (commissionDto.Type == CommissionType.Absolute)
            {
                commission.Value = commissionDto.Value;
            }
            else
            {
                commission.Rate          = commissionDto.Rate;
                commission.MinCommission = commissionDto.MinimalCommission;
                commission.MaxCommission = commissionDto.MaximalCommission;
            }

            return(commission);
        }
Beispiel #6
0
        public bool Post([FromBody] CommissionDto commission)
        {
            Console.WriteLine(commission);

            return(commissionRepository.addCommission(commission));
        }
        public static Task <List <CommissionDto> > ReadCommision(IFormFile file, string fileName, int companyId)
        {
            if (!string.IsNullOrEmpty(fileName))
            {
                fileName += Guid.NewGuid().ToString() + ".xlsx";
            }

            using (FileStream fileStream = System.IO.File.Create(fileName))
            {
                file.CopyTo(fileStream);
                fileStream.Flush();
            }

            var commmisions = new List <CommissionDto>();

            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

            using (var stream = System.IO.File.Open(fileName, FileMode.Open, FileAccess.Read))
            {
                using (var reader = ExcelReaderFactory.CreateReader(stream))
                {
                    while (reader.Read())
                    {
                        if (reader.Depth == 0)
                        {
                            continue;
                        }

                        //commmisions.Add(new CommissionDto()
                        //{
                        //    TransactionId = reader.GetValue(0) != null ? reader.GetValue(0).ToString() : "",
                        //    ProcessType = reader.GetValue(1) != null ? reader.GetValue(1).ToString() : "",
                        //    OrderNumber = reader.GetValue(2) != null ? reader.GetValue(2).ToString() : "",
                        //    OdemeStatus = reader.GetValue(5) != null ? reader.GetValue(5).ToString() : "",
                        //    ProcessDate = reader.GetValue(6) != null ? Convert.ToDateTime(reader.GetValue(6)) : new DateTime(),
                        //    Seller = reader.GetValue(7) != null ? reader.GetValue(7).ToString() : "",
                        //    VendorCurrentName = reader.GetValue(8) != null ? reader.GetValue(8).ToString() : "",
                        //    ProductName = reader.GetValue(9) != null ? reader.GetValue(9).ToString() : "",
                        //    Barcode = reader.GetValue(10) != null ? reader.GetValue(10).ToString() : "",
                        //    CommissionRate = Convert.ToDouble(reader.GetValue(17)),
                        //    TYProgressPayment = Convert.ToDouble(reader.GetValue(17)),
                        //    SellerProgressPayment = Convert.ToDouble(reader.GetValue(17)),
                        //    TermTime = Convert.ToInt32(reader.GetValue(18)),
                        //    AgreeDate = reader.GetValue(6) != null ? Convert.ToDateTime(reader.GetValue(6)) : new DateTime(),
                        //    ShippingDate = reader.GetValue(6) != null ? Convert.ToDateTime(reader.GetValue(6)) : new DateTime(),
                        //    TermDate = reader.GetValue(6) != null ? Convert.ToDateTime(reader.GetValue(6)) : new DateTime(),
                        //    CommissionInvoiceNumber = reader.GetValue(10) != null ? reader.GetValue(10).ToString() : "",
                        //    TotalAmount = Convert.ToDouble(reader.GetValue(17))

                        //});


                        var commission = new CommissionDto();

                        commission.CompanyId     = companyId;
                        commission.TransactionId = reader.GetValue(0) != null?reader.GetValue(0).ToString() : "";

                        commission.ProcessType = reader.GetValue(1) != null?reader.GetValue(1).ToString() : "";

                        commission.OrderNumber = reader.GetValue(2) != null?reader.GetValue(2).ToString() : "";

                        commission.OrderDate   = !string.IsNullOrEmpty(reader.GetValue(3)?.ToString()) ? Convert.ToDateTime(reader.GetValue(3)) : new DateTime();
                        commission.OdemeStatus = reader.GetValue(4) != null?reader.GetValue(4).ToString() : "";

                        commission.ProcessDate = !string.IsNullOrEmpty(reader.GetValue(5)?.ToString()) ? Convert.ToDateTime(reader.GetValue(5)) : new DateTime();
                        commission.Seller      = reader.GetValue(6) != null?reader.GetValue(6).ToString() : "";

                        commission.VendorCurrentName = reader.GetValue(7) != null?reader.GetValue(7).ToString() : "";

                        commission.ProductName = reader.GetValue(8) != null?reader.GetValue(8).ToString() : "";

                        commission.Barcode = reader.GetValue(9) != null?reader.GetValue(9).ToString() : "";

                        commission.CommissionRate        = Convert.ToDouble(reader.GetValue(10));
                        commission.TYProgressPayment     = Convert.ToDouble(reader.GetValue(11));
                        commission.SellerProgressPayment = Convert.ToDouble(reader.GetValue(12));
                        commission.TermTime                = Convert.ToInt32(reader.GetValue(13));
                        commission.AgreeDate               = !string.IsNullOrEmpty(reader.GetValue(14)?.ToString()) ? Convert.ToDateTime(reader.GetValue(14)) : new DateTime();
                        commission.Deliverydate            = !string.IsNullOrEmpty(reader.GetValue(15)?.ToString()) ? Convert.ToDateTime(reader.GetValue(15)) : new DateTime();
                        commission.TermDate                = !string.IsNullOrEmpty(reader.GetValue(16)?.ToString()) ? Convert.ToDateTime(reader.GetValue(16)) : new DateTime();
                        commission.CommissionInvoiceNumber = reader.GetValue(17) != null?reader.GetValue(17).ToString() : "";

                        commission.TotalAmount = Convert.ToDouble(reader.GetValue(18));
                        commission.Name        = reader.GetValue(19) != null?reader.GetValue(19).ToString() : "";

                        commission.Surname = reader.GetValue(20) != null?reader.GetValue(20).ToString() : "";

                        commission.ShippingDate = !string.IsNullOrEmpty(reader.GetValue(21)?.ToString()) ? Convert.ToDateTime(reader.GetValue(21)) : new DateTime();

                        commmisions.Add(commission);
                    }
                }
            }


            // model doldurulduktan sonra file delete
            System.IO.File.Delete(fileName);

            return(Task.FromResult(commmisions));
        }