コード例 #1
0
        public async Task <ActionResult <List <OrderReport_PaymentStatusDTO> > > FilterListPaymentStatus([FromBody] OrderReport_PaymentStatusFilterDTO OrderReport_PaymentStatusFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            PaymentStatusFilter PaymentStatusFilter = new PaymentStatusFilter();

            PaymentStatusFilter.Skip      = 0;
            PaymentStatusFilter.Take      = 20;
            PaymentStatusFilter.OrderBy   = PaymentStatusOrder.Id;
            PaymentStatusFilter.OrderType = OrderType.ASC;
            PaymentStatusFilter.Selects   = PaymentStatusSelect.ALL;
            PaymentStatusFilter.Id        = OrderReport_PaymentStatusFilterDTO.Id;
            PaymentStatusFilter.Name      = OrderReport_PaymentStatusFilterDTO.Name;

            List <PaymentStatus> PaymentStatuses = await PaymentStatusService.List(PaymentStatusFilter);

            List <OrderReport_PaymentStatusDTO> OrderReport_PaymentStatusDTOs = PaymentStatuses
                                                                                .Select(x => new OrderReport_PaymentStatusDTO(x)).ToList();

            return(OrderReport_PaymentStatusDTOs);
        }
コード例 #2
0
        public async Task <int> Count(PaymentStatusFilter filter)
        {
            IQueryable <PaymentStatusDAO> PaymentStatuses = DataContext.PaymentStatus.AsNoTracking();

            PaymentStatuses = DynamicFilter(PaymentStatuses, filter);
            return(await PaymentStatuses.CountAsync());
        }
コード例 #3
0
        public async Task <ActionResult <List <RepairTicket_PaymentStatusDTO> > > SingleListPaymentStatus([FromBody] RepairTicket_PaymentStatusFilterDTO RepairTicket_PaymentStatusFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            PaymentStatusFilter PaymentStatusFilter = new PaymentStatusFilter();

            PaymentStatusFilter.Skip      = 0;
            PaymentStatusFilter.Take      = int.MaxValue;
            PaymentStatusFilter.Take      = 20;
            PaymentStatusFilter.OrderBy   = PaymentStatusOrder.Id;
            PaymentStatusFilter.OrderType = OrderType.ASC;
            PaymentStatusFilter.Selects   = PaymentStatusSelect.ALL;

            List <PaymentStatus> PaymentStatuses = await PaymentStatusService.List(PaymentStatusFilter);

            List <RepairTicket_PaymentStatusDTO> RepairTicket_PaymentStatusDTOs = PaymentStatuses
                                                                                  .Select(x => new RepairTicket_PaymentStatusDTO(x)).ToList();

            return(RepairTicket_PaymentStatusDTOs);
        }
コード例 #4
0
        public async Task <List <PaymentStatus> > List(PaymentStatusFilter filter)
        {
            if (filter == null)
            {
                return(new List <PaymentStatus>());
            }
            IQueryable <PaymentStatusDAO> PaymentStatusDAOs = DataContext.PaymentStatus.AsNoTracking();

            PaymentStatusDAOs = DynamicFilter(PaymentStatusDAOs, filter);
            PaymentStatusDAOs = DynamicOrder(PaymentStatusDAOs, filter);
            List <PaymentStatus> PaymentStatuses = await DynamicSelect(PaymentStatusDAOs, filter);

            return(PaymentStatuses);
        }
コード例 #5
0
        public async Task <List <PaymentStatus> > List(PaymentStatusFilter PaymentStatusFilter)
        {
            try
            {
                List <PaymentStatus> PaymentStatuss = await UOW.PaymentStatusRepository.List(PaymentStatusFilter);

                return(PaymentStatuss);
            }
            catch (Exception ex)
            {
                await Logging.CreateSystemLog(ex, nameof(PaymentStatusService));
            }
            return(null);
        }
コード例 #6
0
        public async Task <int> Count(PaymentStatusFilter PaymentStatusFilter)
        {
            try
            {
                int result = await UOW.PaymentStatusRepository.Count(PaymentStatusFilter);

                return(result);
            }
            catch (Exception ex)
            {
                await Logging.CreateSystemLog(ex, nameof(PaymentStatusService));
            }
            return(0);
        }
コード例 #7
0
        public async Task <bool> ValidateId(PaymentStatus PaymentStatus)
        {
            PaymentStatusFilter PaymentStatusFilter = new PaymentStatusFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = PaymentStatus.Id
                },
                Selects = PaymentStatusSelect.Id
            };

            int count = await UOW.PaymentStatusRepository.Count(PaymentStatusFilter);

            if (count == 0)
            {
                PaymentStatus.AddError(nameof(PaymentStatusValidator), nameof(PaymentStatus.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
コード例 #8
0
        private IQueryable <PaymentStatusDAO> DynamicOrder(IQueryable <PaymentStatusDAO> query, PaymentStatusFilter filter)
        {
            switch (filter.OrderType)
            {
            case OrderType.ASC:
                switch (filter.OrderBy)
                {
                case PaymentStatusOrder.Id:
                    query = query.OrderBy(q => q.Id);
                    break;

                case PaymentStatusOrder.Code:
                    query = query.OrderBy(q => q.Code);
                    break;

                case PaymentStatusOrder.Name:
                    query = query.OrderBy(q => q.Name);
                    break;
                }
                break;

            case OrderType.DESC:
                switch (filter.OrderBy)
                {
                case PaymentStatusOrder.Id:
                    query = query.OrderByDescending(q => q.Id);
                    break;

                case PaymentStatusOrder.Code:
                    query = query.OrderByDescending(q => q.Code);
                    break;

                case PaymentStatusOrder.Name:
                    query = query.OrderByDescending(q => q.Name);
                    break;
                }
                break;
            }
            query = query.Skip(filter.Skip).Take(filter.Take);
            return(query);
        }
コード例 #9
0
        private IQueryable <PaymentStatusDAO> OrFilter(IQueryable <PaymentStatusDAO> query, PaymentStatusFilter filter)
        {
            if (filter.OrFilter == null || filter.OrFilter.Count == 0)
            {
                return(query);
            }
            IQueryable <PaymentStatusDAO> initQuery = query.Where(q => false);

            foreach (PaymentStatusFilter PaymentStatusFilter in filter.OrFilter)
            {
                IQueryable <PaymentStatusDAO> queryable = query;
                if (PaymentStatusFilter.Id != null && PaymentStatusFilter.Id.HasValue)
                {
                    queryable = queryable.Where(q => q.Id, PaymentStatusFilter.Id);
                }
                if (PaymentStatusFilter.Code != null && PaymentStatusFilter.Code.HasValue)
                {
                    queryable = queryable.Where(q => q.Code, PaymentStatusFilter.Code);
                }
                if (PaymentStatusFilter.Name != null && PaymentStatusFilter.Name.HasValue)
                {
                    queryable = queryable.Where(q => q.Name, PaymentStatusFilter.Name);
                }
                initQuery = initQuery.Union(queryable);
            }
            return(initQuery);
        }
コード例 #10
0
 private IQueryable <PaymentStatusDAO> DynamicFilter(IQueryable <PaymentStatusDAO> query, PaymentStatusFilter filter)
 {
     if (filter == null)
     {
         return(query.Where(q => false));
     }
     if (filter.Id != null && filter.Id.HasValue)
     {
         query = query.Where(q => q.Id, filter.Id);
     }
     if (filter.Code != null && filter.Code.HasValue)
     {
         query = query.Where(q => q.Code, filter.Code);
     }
     if (filter.Name != null && filter.Name.HasValue)
     {
         query = query.Where(q => q.Name, filter.Name);
     }
     query = OrFilter(query, filter);
     return(query);
 }
コード例 #11
0
        private async Task <List <PaymentStatus> > DynamicSelect(IQueryable <PaymentStatusDAO> query, PaymentStatusFilter filter)
        {
            List <PaymentStatus> PaymentStatuses = await query.Select(q => new PaymentStatus()
            {
                Id   = filter.Selects.Contains(PaymentStatusSelect.Id) ? q.Id : default(long),
                Code = filter.Selects.Contains(PaymentStatusSelect.Code) ? q.Code : default(string),
                Name = filter.Selects.Contains(PaymentStatusSelect.Name) ? q.Name : default(string),
            }).ToListAsync();

            return(PaymentStatuses);
        }
コード例 #12
0
        public async Task <ActionResult> Export([FromBody] RepairTicket_RepairTicketFilterDTO RepairTicket_RepairTicketFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            MemoryStream memoryStream = new MemoryStream();

            using (ExcelPackage excel = new ExcelPackage(memoryStream))
            {
                #region RepairTicket
                var RepairTicketFilter = ConvertFilterDTOToFilterEntity(RepairTicket_RepairTicketFilterDTO);
                RepairTicketFilter.Skip = 0;
                RepairTicketFilter.Take = int.MaxValue;
                RepairTicketFilter      = await RepairTicketService.ToFilter(RepairTicketFilter);

                List <RepairTicket> RepairTickets = await RepairTicketService.List(RepairTicketFilter);

                var RepairTicketHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "Code",
                        "OrderId",
                        "OrderCategoryId",
                        "RepairDueDate",
                        "ItemId",
                        "IsRejectRepair",
                        "RejectReason",
                        "DeviceState",
                        "RepairStatusId",
                        "RepairAddess",
                        "ReceiveUser",
                        "ReceiveDate",
                        "RepairDate",
                        "ReturnDate",
                        "RepairSolution",
                        "Note",
                        "RepairCost",
                        "PaymentStatusId",
                        "CustomerId",
                        "CreatorId",
                    }
                };
                List <object[]> RepairTicketData = new List <object[]>();
                for (int i = 0; i < RepairTickets.Count; i++)
                {
                    var RepairTicket = RepairTickets[i];
                    RepairTicketData.Add(new Object[]
                    {
                        RepairTicket.Id,
                        RepairTicket.Code,
                        RepairTicket.OrderId,
                        RepairTicket.OrderCategoryId,
                        RepairTicket.RepairDueDate,
                        RepairTicket.ItemId,
                        RepairTicket.IsRejectRepair,
                        RepairTicket.RejectReason,
                        RepairTicket.DeviceState,
                        RepairTicket.RepairStatusId,
                        RepairTicket.RepairAddess,
                        RepairTicket.ReceiveUser,
                        RepairTicket.ReceiveDate,
                        RepairTicket.RepairDate,
                        RepairTicket.ReturnDate,
                        RepairTicket.RepairSolution,
                        RepairTicket.Note,
                        RepairTicket.RepairCost,
                        RepairTicket.PaymentStatusId,
                        RepairTicket.CustomerId,
                        RepairTicket.CreatorId,
                    });
                }
                excel.GenerateWorksheet("RepairTicket", RepairTicketHeaders, RepairTicketData);
                #endregion

                #region AppUser
                var AppUserFilter = new AppUserFilter();
                AppUserFilter.Selects   = AppUserSelect.ALL;
                AppUserFilter.OrderBy   = AppUserOrder.Id;
                AppUserFilter.OrderType = OrderType.ASC;
                AppUserFilter.Skip      = 0;
                AppUserFilter.Take      = int.MaxValue;
                List <AppUser> AppUsers = await AppUserService.List(AppUserFilter);

                var AppUserHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "Username",
                        "DisplayName",
                        "Address",
                        "Email",
                        "Phone",
                        "SexId",
                        "Birthday",
                        "Avatar",
                        "Department",
                        "OrganizationId",
                        "Longitude",
                        "Latitude",
                        "StatusId",
                        "RowId",
                        "Used",
                    }
                };
                List <object[]> AppUserData = new List <object[]>();
                for (int i = 0; i < AppUsers.Count; i++)
                {
                    var AppUser = AppUsers[i];
                    AppUserData.Add(new Object[]
                    {
                        AppUser.Id,
                        AppUser.Username,
                        AppUser.DisplayName,
                        AppUser.Address,
                        AppUser.Email,
                        AppUser.Phone,
                        AppUser.SexId,
                        AppUser.Birthday,
                        AppUser.Avatar,
                        AppUser.Department,
                        AppUser.OrganizationId,
                        AppUser.Longitude,
                        AppUser.Latitude,
                        AppUser.StatusId,
                        AppUser.RowId,
                        AppUser.Used,
                    });
                }
                excel.GenerateWorksheet("AppUser", AppUserHeaders, AppUserData);
                #endregion
                #region Customer
                var CustomerFilter = new CustomerFilter();
                CustomerFilter.Selects   = CustomerSelect.ALL;
                CustomerFilter.OrderBy   = CustomerOrder.Id;
                CustomerFilter.OrderType = OrderType.ASC;
                CustomerFilter.Skip      = 0;
                CustomerFilter.Take      = int.MaxValue;
                List <Customer> Customers = await CustomerService.List(CustomerFilter);

                var CustomerHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "Code",
                        "FullName",
                        "Phone",
                        "IdentificationNumber",
                        "Email",
                        "Address",
                        "StatusId",
                        "NationId",
                        "ProvinceId",
                        "DistrictId",
                        "WardId",
                        "CreatorId",
                        "OrganizationId",
                        "ImageId",
                        "ProfessionId",
                        "Used",
                    }
                };
                List <object[]> CustomerData = new List <object[]>();
                for (int i = 0; i < Customers.Count; i++)
                {
                    var Customer = Customers[i];
                    CustomerData.Add(new Object[]
                    {
                        Customer.Id,
                        Customer.Code,
                        Customer.Name,
                        Customer.Phone,
                        Customer.Email,
                        Customer.Address,
                        Customer.StatusId,
                        Customer.NationId,
                        Customer.ProvinceId,
                        Customer.DistrictId,
                        Customer.WardId,
                        Customer.ProfessionId,
                        Customer.Used,
                    });
                }
                excel.GenerateWorksheet("Customer", CustomerHeaders, CustomerData);
                #endregion
                #region Item
                var ItemFilter = new ItemFilter();
                ItemFilter.Selects   = ItemSelect.ALL;
                ItemFilter.OrderBy   = ItemOrder.Id;
                ItemFilter.OrderType = OrderType.ASC;
                ItemFilter.Skip      = 0;
                ItemFilter.Take      = int.MaxValue;
                List <Item> Items = await ItemService.List(ItemFilter);

                var ItemHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "ProductId",
                        "Code",
                        "Name",
                        "ScanCode",
                        "SalePrice",
                        "RetailPrice",
                        "StatusId",
                        "Used",
                        "RowId",
                    }
                };
                List <object[]> ItemData = new List <object[]>();
                for (int i = 0; i < Items.Count; i++)
                {
                    var Item = Items[i];
                    ItemData.Add(new Object[]
                    {
                        Item.Id,
                        Item.ProductId,
                        Item.Code,
                        Item.Name,
                        Item.ScanCode,
                        Item.SalePrice,
                        Item.RetailPrice,
                        Item.StatusId,
                        Item.Used,
                        Item.RowId,
                    });
                }
                excel.GenerateWorksheet("Item", ItemHeaders, ItemData);
                #endregion
                #region OrderCategory
                var OrderCategoryFilter = new OrderCategoryFilter();
                OrderCategoryFilter.Selects   = OrderCategorySelect.ALL;
                OrderCategoryFilter.OrderBy   = OrderCategoryOrder.Id;
                OrderCategoryFilter.OrderType = OrderType.ASC;
                OrderCategoryFilter.Skip      = 0;
                OrderCategoryFilter.Take      = int.MaxValue;
                List <OrderCategory> OrderCategorys = await OrderCategoryService.List(OrderCategoryFilter);

                var OrderCategoryHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "Code",
                        "Name",
                    }
                };
                List <object[]> OrderCategoryData = new List <object[]>();
                for (int i = 0; i < OrderCategorys.Count; i++)
                {
                    var OrderCategory = OrderCategorys[i];
                    OrderCategoryData.Add(new Object[]
                    {
                        OrderCategory.Id,
                        OrderCategory.Code,
                        OrderCategory.Name,
                    });
                }
                excel.GenerateWorksheet("OrderCategory", OrderCategoryHeaders, OrderCategoryData);
                #endregion
                #region PaymentStatus
                var PaymentStatusFilter = new PaymentStatusFilter();
                PaymentStatusFilter.Selects   = PaymentStatusSelect.ALL;
                PaymentStatusFilter.OrderBy   = PaymentStatusOrder.Id;
                PaymentStatusFilter.OrderType = OrderType.ASC;
                PaymentStatusFilter.Skip      = 0;
                PaymentStatusFilter.Take      = int.MaxValue;
                List <PaymentStatus> PaymentStatuses = await PaymentStatusService.List(PaymentStatusFilter);

                var PaymentStatusHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "Code",
                        "Name",
                    }
                };
                List <object[]> PaymentStatusData = new List <object[]>();
                for (int i = 0; i < PaymentStatuses.Count; i++)
                {
                    var PaymentStatus = PaymentStatuses[i];
                    PaymentStatusData.Add(new Object[]
                    {
                        PaymentStatus.Id,
                        PaymentStatus.Code,
                        PaymentStatus.Name,
                    });
                }
                excel.GenerateWorksheet("PaymentStatus", PaymentStatusHeaders, PaymentStatusData);
                #endregion
                #region RepairStatus
                var RepairStatusFilter = new RepairStatusFilter();
                RepairStatusFilter.Selects   = RepairStatusSelect.ALL;
                RepairStatusFilter.OrderBy   = RepairStatusOrder.Id;
                RepairStatusFilter.OrderType = OrderType.ASC;
                RepairStatusFilter.Skip      = 0;
                RepairStatusFilter.Take      = int.MaxValue;
                List <RepairStatus> RepairStatuses = await RepairStatusService.List(RepairStatusFilter);

                var RepairStatusHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "Name",
                        "Code",
                    }
                };
                List <object[]> RepairStatusData = new List <object[]>();
                for (int i = 0; i < RepairStatuses.Count; i++)
                {
                    var RepairStatus = RepairStatuses[i];
                    RepairStatusData.Add(new Object[]
                    {
                        RepairStatus.Id,
                        RepairStatus.Name,
                        RepairStatus.Code,
                    });
                }
                excel.GenerateWorksheet("RepairStatus", RepairStatusHeaders, RepairStatusData);
                #endregion
                excel.Save();
            }
            return(File(memoryStream.ToArray(), "application/octet-stream", "RepairTicket.xlsx"));
        }
コード例 #13
0
        public async Task <ActionResult> Import(IFormFile file)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }
            AppUserFilter CreatorFilter = new AppUserFilter
            {
                Skip    = 0,
                Take    = int.MaxValue,
                Selects = AppUserSelect.ALL
            };
            List <AppUser> Creators = await AppUserService.List(CreatorFilter);

            CustomerFilter CustomerFilter = new CustomerFilter
            {
                Skip    = 0,
                Take    = int.MaxValue,
                Selects = CustomerSelect.ALL
            };
            List <Customer> Customers = await CustomerService.List(CustomerFilter);

            ItemFilter ItemFilter = new ItemFilter
            {
                Skip    = 0,
                Take    = int.MaxValue,
                Selects = ItemSelect.ALL
            };
            List <Item> Items = await ItemService.List(ItemFilter);

            OrderCategoryFilter OrderCategoryFilter = new OrderCategoryFilter
            {
                Skip    = 0,
                Take    = int.MaxValue,
                Selects = OrderCategorySelect.ALL
            };
            List <OrderCategory> OrderCategorys = await OrderCategoryService.List(OrderCategoryFilter);

            PaymentStatusFilter PaymentStatusFilter = new PaymentStatusFilter
            {
                Skip    = 0,
                Take    = int.MaxValue,
                Selects = PaymentStatusSelect.ALL
            };
            List <PaymentStatus> PaymentStatuses = await PaymentStatusService.List(PaymentStatusFilter);

            RepairStatusFilter RepairStatusFilter = new RepairStatusFilter
            {
                Skip    = 0,
                Take    = int.MaxValue,
                Selects = RepairStatusSelect.ALL
            };
            List <RepairStatus> RepairStatuses = await RepairStatusService.List(RepairStatusFilter);

            List <RepairTicket> RepairTickets = new List <RepairTicket>();

            using (ExcelPackage excelPackage = new ExcelPackage(file.OpenReadStream()))
            {
                ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.FirstOrDefault();
                if (worksheet == null)
                {
                    return(Ok(RepairTickets));
                }
                int StartColumn           = 1;
                int StartRow              = 1;
                int IdColumn              = 0 + StartColumn;
                int CodeColumn            = 1 + StartColumn;
                int OrderIdColumn         = 2 + StartColumn;
                int OrderCategoryIdColumn = 3 + StartColumn;
                int RepairDueDateColumn   = 4 + StartColumn;
                int ItemIdColumn          = 5 + StartColumn;
                int IsRejectRepairColumn  = 6 + StartColumn;
                int RejectReasonColumn    = 7 + StartColumn;
                int DeviceStateColumn     = 8 + StartColumn;
                int RepairStatusIdColumn  = 9 + StartColumn;
                int RepairAddessColumn    = 10 + StartColumn;
                int ReceiveUserColumn     = 11 + StartColumn;
                int ReceiveDateColumn     = 12 + StartColumn;
                int RepairDateColumn      = 13 + StartColumn;
                int ReturnDateColumn      = 14 + StartColumn;
                int RepairSolutionColumn  = 15 + StartColumn;
                int NoteColumn            = 16 + StartColumn;
                int RepairCostColumn      = 17 + StartColumn;
                int PaymentStatusIdColumn = 18 + StartColumn;
                int CustomerIdColumn      = 19 + StartColumn;
                int CreatorIdColumn       = 20 + StartColumn;

                for (int i = StartRow; i <= worksheet.Dimension.End.Row; i++)
                {
                    if (string.IsNullOrEmpty(worksheet.Cells[i + StartRow, StartColumn].Value?.ToString()))
                    {
                        break;
                    }
                    string IdValue              = worksheet.Cells[i + StartRow, IdColumn].Value?.ToString();
                    string CodeValue            = worksheet.Cells[i + StartRow, CodeColumn].Value?.ToString();
                    string OrderIdValue         = worksheet.Cells[i + StartRow, OrderIdColumn].Value?.ToString();
                    string OrderCategoryIdValue = worksheet.Cells[i + StartRow, OrderCategoryIdColumn].Value?.ToString();
                    string RepairDueDateValue   = worksheet.Cells[i + StartRow, RepairDueDateColumn].Value?.ToString();
                    string ItemIdValue          = worksheet.Cells[i + StartRow, ItemIdColumn].Value?.ToString();
                    string IsRejectRepairValue  = worksheet.Cells[i + StartRow, IsRejectRepairColumn].Value?.ToString();
                    string RejectReasonValue    = worksheet.Cells[i + StartRow, RejectReasonColumn].Value?.ToString();
                    string DeviceStateValue     = worksheet.Cells[i + StartRow, DeviceStateColumn].Value?.ToString();
                    string RepairStatusIdValue  = worksheet.Cells[i + StartRow, RepairStatusIdColumn].Value?.ToString();
                    string RepairAddessValue    = worksheet.Cells[i + StartRow, RepairAddessColumn].Value?.ToString();
                    string ReceiveUserValue     = worksheet.Cells[i + StartRow, ReceiveUserColumn].Value?.ToString();
                    string ReceiveDateValue     = worksheet.Cells[i + StartRow, ReceiveDateColumn].Value?.ToString();
                    string RepairDateValue      = worksheet.Cells[i + StartRow, RepairDateColumn].Value?.ToString();
                    string ReturnDateValue      = worksheet.Cells[i + StartRow, ReturnDateColumn].Value?.ToString();
                    string RepairSolutionValue  = worksheet.Cells[i + StartRow, RepairSolutionColumn].Value?.ToString();
                    string NoteValue            = worksheet.Cells[i + StartRow, NoteColumn].Value?.ToString();
                    string RepairCostValue      = worksheet.Cells[i + StartRow, RepairCostColumn].Value?.ToString();
                    string PaymentStatusIdValue = worksheet.Cells[i + StartRow, PaymentStatusIdColumn].Value?.ToString();
                    string CustomerIdValue      = worksheet.Cells[i + StartRow, CustomerIdColumn].Value?.ToString();
                    string CreatorIdValue       = worksheet.Cells[i + StartRow, CreatorIdColumn].Value?.ToString();

                    RepairTicket RepairTicket = new RepairTicket();
                    RepairTicket.Code           = CodeValue;
                    RepairTicket.RepairDueDate  = DateTime.TryParse(RepairDueDateValue, out DateTime RepairDueDate) ? RepairDueDate : DateTime.Now;
                    RepairTicket.RejectReason   = RejectReasonValue;
                    RepairTicket.DeviceState    = DeviceStateValue;
                    RepairTicket.RepairAddess   = RepairAddessValue;
                    RepairTicket.ReceiveUser    = ReceiveUserValue;
                    RepairTicket.ReceiveDate    = DateTime.TryParse(ReceiveDateValue, out DateTime ReceiveDate) ? ReceiveDate : DateTime.Now;
                    RepairTicket.RepairDate     = DateTime.TryParse(RepairDateValue, out DateTime RepairDate) ? RepairDate : DateTime.Now;
                    RepairTicket.ReturnDate     = DateTime.TryParse(ReturnDateValue, out DateTime ReturnDate) ? ReturnDate : DateTime.Now;
                    RepairTicket.RepairSolution = RepairSolutionValue;
                    RepairTicket.Note           = NoteValue;
                    RepairTicket.RepairCost     = decimal.TryParse(RepairCostValue, out decimal RepairCost) ? RepairCost : 0;
                    AppUser Creator = Creators.Where(x => x.Id.ToString() == CreatorIdValue).FirstOrDefault();
                    RepairTicket.CreatorId = Creator == null ? 0 : Creator.Id;
                    RepairTicket.Creator   = Creator;
                    Customer Customer = Customers.Where(x => x.Id.ToString() == CustomerIdValue).FirstOrDefault();
                    RepairTicket.CustomerId = Customer == null ? 0 : Customer.Id;
                    RepairTicket.Customer   = Customer;
                    Item Item = Items.Where(x => x.Id.ToString() == ItemIdValue).FirstOrDefault();
                    RepairTicket.ItemId = Item == null ? 0 : Item.Id;
                    RepairTicket.Item   = Item;
                    OrderCategory OrderCategory = OrderCategorys.Where(x => x.Id.ToString() == OrderCategoryIdValue).FirstOrDefault();
                    RepairTicket.OrderCategoryId = OrderCategory == null ? 0 : OrderCategory.Id;
                    RepairTicket.OrderCategory   = OrderCategory;
                    PaymentStatus PaymentStatus = PaymentStatuses.Where(x => x.Id.ToString() == PaymentStatusIdValue).FirstOrDefault();
                    RepairTicket.PaymentStatusId = PaymentStatus == null ? 0 : PaymentStatus.Id;
                    RepairTicket.PaymentStatus   = PaymentStatus;
                    RepairStatus RepairStatus = RepairStatuses.Where(x => x.Id.ToString() == RepairStatusIdValue).FirstOrDefault();
                    RepairTicket.RepairStatusId = RepairStatus == null ? 0 : RepairStatus.Id;
                    RepairTicket.RepairStatus   = RepairStatus;

                    RepairTickets.Add(RepairTicket);
                }
            }
            RepairTickets = await RepairTicketService.Import(RepairTickets);

            if (RepairTickets.All(x => x.IsValidated))
            {
                return(Ok(true));
            }
            else
            {
                List <string> Errors = new List <string>();
                for (int i = 0; i < RepairTickets.Count; i++)
                {
                    RepairTicket RepairTicket = RepairTickets[i];
                    if (!RepairTicket.IsValidated)
                    {
                        string Error = $"Dòng {i + 2} có lỗi:";
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.Id)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.Id)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.Code)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.Code)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.OrderId)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.OrderId)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.OrderCategoryId)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.OrderCategoryId)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.RepairDueDate)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.RepairDueDate)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.ItemId)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.ItemId)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.IsRejectRepair)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.IsRejectRepair)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.RejectReason)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.RejectReason)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.DeviceState)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.DeviceState)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.RepairStatusId)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.RepairStatusId)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.RepairAddess)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.RepairAddess)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.ReceiveUser)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.ReceiveUser)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.ReceiveDate)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.ReceiveDate)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.RepairDate)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.RepairDate)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.ReturnDate)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.ReturnDate)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.RepairSolution)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.RepairSolution)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.Note)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.Note)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.RepairCost)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.RepairCost)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.PaymentStatusId)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.PaymentStatusId)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.CustomerId)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.CustomerId)];
                        }
                        if (RepairTicket.Errors.ContainsKey(nameof(RepairTicket.CreatorId)))
                        {
                            Error += RepairTicket.Errors[nameof(RepairTicket.CreatorId)];
                        }
                        Errors.Add(Error);
                    }
                }
                return(BadRequest(Errors));
            }
        }