Esempio n. 1
0
        public async Task <CustomerGrouping> Update(CustomerGrouping CustomerGrouping)
        {
            if (!await CustomerGroupingValidator.Update(CustomerGrouping))
            {
                return(CustomerGrouping);
            }
            try
            {
                var oldData = await UOW.CustomerGroupingRepository.Get(CustomerGrouping.Id);

                await UOW.Begin();

                await UOW.CustomerGroupingRepository.Update(CustomerGrouping);

                await UOW.Commit();

                var newData = await UOW.CustomerGroupingRepository.Get(CustomerGrouping.Id);

                await UOW.AuditLogRepository.Create(newData, oldData, nameof(CustomerGroupingService));

                return(newData);
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(CustomerGroupingService));

                throw new MessageException(ex);
            }
        }
Esempio n. 2
0
        public async Task <Customer> CreateCustomer(Customer customer)
        {
            string url = $"{_chargifyUrl}/customers.json";

            var customerGrouping = new CustomerGrouping()
            {
                customer = customer
            };

            using (var request = new HttpRequestMessage(HttpMethod.Post, url))
            {
                request.Content = new StringContent(
                    JsonConvert.SerializeObject(customerGrouping),
                    Encoding.UTF8,
                    "application/json");;

                AuthorizeRequest(request);

                using (var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead))
                {
                    var result = await ProcessResponse <CustomerGrouping>(response);

                    return(result?.customer);
                }
            }
        }
Esempio n. 3
0
        public async Task <ActionResult <CustomerGrouping_CustomerGroupingDTO> > Delete([FromBody] CustomerGrouping_CustomerGroupingDTO CustomerGrouping_CustomerGroupingDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(CustomerGrouping_CustomerGroupingDTO.Id))
            {
                return(Forbid());
            }

            CustomerGrouping CustomerGrouping = ConvertDTOToEntity(CustomerGrouping_CustomerGroupingDTO);

            CustomerGrouping = await CustomerGroupingService.Delete(CustomerGrouping);

            CustomerGrouping_CustomerGroupingDTO = new CustomerGrouping_CustomerGroupingDTO(CustomerGrouping);
            if (CustomerGrouping.IsValidated)
            {
                return(CustomerGrouping_CustomerGroupingDTO);
            }
            else
            {
                return(BadRequest(CustomerGrouping_CustomerGroupingDTO));
            }
        }
 public async Task <bool> Delete(CustomerGrouping CustomerGrouping)
 {
     if (await ValidateId(CustomerGrouping))
     {
     }
     return(CustomerGrouping.IsValidated);
 }
        public async Task <bool> Update(CustomerGrouping CustomerGrouping)
        {
            CustomerGroupingDAO CustomerGroupingDAO = DataContext.CustomerGrouping.Where(x => x.Id == CustomerGrouping.Id).FirstOrDefault();

            if (CustomerGroupingDAO == null)
            {
                return(false);
            }
            CustomerGroupingDAO.Id             = CustomerGrouping.Id;
            CustomerGroupingDAO.Code           = CustomerGrouping.Code;
            CustomerGroupingDAO.Name           = CustomerGrouping.Name;
            CustomerGroupingDAO.CustomerTypeId = CustomerGrouping.CustomerTypeId;
            CustomerGroupingDAO.ParentId       = CustomerGrouping.ParentId;
            CustomerGroupingDAO.Path           = CustomerGrouping.Path;
            CustomerGroupingDAO.Level          = CustomerGrouping.Level;
            CustomerGroupingDAO.StatusId       = CustomerGrouping.StatusId;
            CustomerGroupingDAO.Description    = CustomerGrouping.Description;
            CustomerGroupingDAO.Path           = "";
            CustomerGroupingDAO.Level          = 1;
            CustomerGroupingDAO.UpdatedAt      = StaticParams.DateTimeNow;
            await DataContext.SaveChangesAsync();

            await SaveReference(CustomerGrouping);
            await BuildPath();

            return(true);
        }
        public async Task <bool> Create(CustomerGrouping CustomerGrouping)
        {
            CustomerGroupingDAO CustomerGroupingDAO = new CustomerGroupingDAO();

            CustomerGroupingDAO.Id             = CustomerGrouping.Id;
            CustomerGroupingDAO.Code           = CustomerGrouping.Code;
            CustomerGroupingDAO.Name           = CustomerGrouping.Name;
            CustomerGroupingDAO.CustomerTypeId = CustomerGrouping.CustomerTypeId;
            CustomerGroupingDAO.ParentId       = CustomerGrouping.ParentId;
            CustomerGroupingDAO.Path           = CustomerGrouping.Path;
            CustomerGroupingDAO.Level          = CustomerGrouping.Level;
            CustomerGroupingDAO.StatusId       = CustomerGrouping.StatusId;
            CustomerGroupingDAO.Description    = CustomerGrouping.Description;
            CustomerGroupingDAO.Path           = "";
            CustomerGroupingDAO.Level          = 1;
            CustomerGroupingDAO.CreatedAt      = StaticParams.DateTimeNow;
            CustomerGroupingDAO.UpdatedAt      = StaticParams.DateTimeNow;
            DataContext.CustomerGrouping.Add(CustomerGroupingDAO);
            await DataContext.SaveChangesAsync();

            CustomerGrouping.Id = CustomerGroupingDAO.Id;
            await SaveReference(CustomerGrouping);
            await BuildPath();

            return(true);
        }
Esempio n. 7
0
        public async Task <CustomerGrouping> Delete(CustomerGrouping CustomerGrouping)
        {
            if (!await CustomerGroupingValidator.Delete(CustomerGrouping))
            {
                return(CustomerGrouping);
            }

            try
            {
                await UOW.Begin();

                await UOW.CustomerGroupingRepository.Delete(CustomerGrouping);

                await UOW.Commit();

                await UOW.AuditLogRepository.Create("", CustomerGrouping, nameof(CustomerGroupingService));

                return(CustomerGrouping);
            }
            catch (Exception ex)
            {
                await UOW.Rollback();

                await UOW.SystemLogRepository.Create(ex, nameof(CustomerGroupingService));

                throw new MessageException(ex);
            }
        }
Esempio n. 8
0
        public CustomerGrouping ConvertDTOToEntity(CustomerGroupingDetail_CustomerGroupingDTO CustomerGroupingDetail_CustomerGroupingDTO)
        {
            CustomerGrouping CustomerGrouping = new CustomerGrouping();

            CustomerGrouping.Id   = CustomerGroupingDetail_CustomerGroupingDTO.Id;
            CustomerGrouping.Name = CustomerGroupingDetail_CustomerGroupingDTO.Name;
            return(CustomerGrouping);
        }
Esempio n. 9
0
        public async Task <bool> Delete(CustomerGrouping CustomerGrouping)
        {
            CustomerGroupingDAO CustomerGroupingDAO = await DataContext.CustomerGrouping.Where(x => x.Id == CustomerGrouping.Id).FirstOrDefaultAsync();

            DataContext.CustomerGrouping.Remove(CustomerGroupingDAO);
            await DataContext.SaveChangesAsync();

            return(true);
        }
Esempio n. 10
0
        public async Task <CustomerGrouping> Get(long Id)
        {
            CustomerGrouping CustomerGrouping = await UOW.CustomerGroupingRepository.Get(Id);

            if (CustomerGrouping == null)
            {
                return(null);
            }
            return(CustomerGrouping);
        }
Esempio n. 11
0
        public async Task <CustomerGrouping> Get(long Id)
        {
            CustomerGrouping CustomerGrouping = await DataContext.CustomerGrouping.Where(x => x.Id == Id).Select(CustomerGroupingDAO => new CustomerGrouping()
            {
                Id   = CustomerGroupingDAO.Id,
                Name = CustomerGroupingDAO.Name,
            }).FirstOrDefaultAsync();

            return(CustomerGrouping);
        }
Esempio n. 12
0
        public async Task <bool> Update(CustomerGrouping CustomerGrouping)
        {
            CustomerGroupingDAO CustomerGroupingDAO = DataContext.CustomerGrouping.Where(x => x.Id == CustomerGrouping.Id).FirstOrDefault();

            CustomerGroupingDAO.Id   = CustomerGrouping.Id;
            CustomerGroupingDAO.Name = CustomerGrouping.Name;
            await DataContext.SaveChangesAsync();

            return(true);
        }
        public async Task <CustomerGroupingMaster_CustomerGroupingDTO> Get([FromBody] CustomerGroupingMaster_CustomerGroupingDTO CustomerGroupingMaster_CustomerGroupingDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            CustomerGrouping CustomerGrouping = await CustomerGroupingService.Get(CustomerGroupingMaster_CustomerGroupingDTO.Id);

            return(new CustomerGroupingMaster_CustomerGroupingDTO(CustomerGrouping));
        }
Esempio n. 14
0
 public CallLog_CustomerGroupDTO(CustomerGrouping CustomerGrouping)
 {
     this.Id             = CustomerGrouping.Id;
     this.Name           = CustomerGrouping.Name;
     this.Code           = CustomerGrouping.Code;
     this.Path           = CustomerGrouping.Path;
     this.CustomerTypeId = CustomerGrouping.CustomerTypeId;
     this.Level          = CustomerGrouping.Level;
     this.StatusId       = CustomerGrouping.StatusId;
     this.Description    = CustomerGrouping.Description;
     this.ParentId       = CustomerGrouping.ParentId;
     this.Errors         = CustomerGrouping.Errors;
 }
        public async Task <CustomerGrouping> Get(long Id)
        {
            CustomerGrouping CustomerGrouping = await DataContext.CustomerGrouping.AsNoTracking()
                                                .Where(x => x.Id == Id)
                                                .Where(x => x.DeletedAt == null)
                                                .Select(x => new CustomerGrouping()
            {
                CreatedAt      = x.CreatedAt,
                UpdatedAt      = x.UpdatedAt,
                Id             = x.Id,
                Code           = x.Code,
                Name           = x.Name,
                CustomerTypeId = x.CustomerTypeId,
                ParentId       = x.ParentId,
                Path           = x.Path,
                Level          = x.Level,
                StatusId       = x.StatusId,
                Description    = x.Description,
                CustomerType   = x.CustomerType == null ? null : new CustomerType
                {
                    Id   = x.CustomerType.Id,
                    Code = x.CustomerType.Code,
                    Name = x.CustomerType.Name,
                },
                Parent = x.Parent == null ? null : new CustomerGrouping
                {
                    Id             = x.Parent.Id,
                    Code           = x.Parent.Code,
                    Name           = x.Parent.Name,
                    CustomerTypeId = x.Parent.CustomerTypeId,
                    ParentId       = x.Parent.ParentId,
                    Path           = x.Parent.Path,
                    Level          = x.Parent.Level,
                    StatusId       = x.Parent.StatusId,
                    Description    = x.Parent.Description,
                },
                Status = x.Status == null ? null : new Status
                {
                    Id   = x.Status.Id,
                    Code = x.Status.Code,
                    Name = x.Status.Name,
                },
            }).FirstOrDefaultAsync();

            if (CustomerGrouping == null)
            {
                return(null);
            }

            return(CustomerGrouping);
        }
Esempio n. 16
0
        public async Task <bool> Create(CustomerGrouping CustomerGrouping)
        {
            CustomerGroupingDAO CustomerGroupingDAO = new CustomerGroupingDAO();

            CustomerGroupingDAO.Id   = CustomerGrouping.Id;
            CustomerGroupingDAO.Name = CustomerGrouping.Name;

            await DataContext.CustomerGrouping.AddAsync(CustomerGroupingDAO);

            await DataContext.SaveChangesAsync();

            CustomerGrouping.Id = CustomerGroupingDAO.Id;
            return(true);
        }
        public async Task <bool> Delete(CustomerGrouping CustomerGrouping)
        {
            CustomerGroupingDAO CustomerGroupingDAO = await DataContext.CustomerGrouping.Where(x => x.Id == CustomerGrouping.Id).FirstOrDefaultAsync();

            await DataContext.CustomerGrouping.Where(x => x.Path.StartsWith(CustomerGroupingDAO.Id + ".")).UpdateFromQueryAsync(x => new CustomerGroupingDAO {
                DeletedAt = StaticParams.DateTimeNow, UpdatedAt = StaticParams.DateTimeNow
            });

            await DataContext.CustomerGrouping.Where(x => x.Id == CustomerGrouping.Id).UpdateFromQueryAsync(x => new CustomerGroupingDAO {
                DeletedAt = StaticParams.DateTimeNow, UpdatedAt = StaticParams.DateTimeNow
            });

            await BuildPath();

            return(true);
        }
 public CustomerGrouping_CustomerGroupingDTO(CustomerGrouping CustomerGrouping)
 {
     this.Id             = CustomerGrouping.Id;
     this.Code           = CustomerGrouping.Code;
     this.Name           = CustomerGrouping.Name;
     this.CustomerTypeId = CustomerGrouping.CustomerTypeId;
     this.ParentId       = CustomerGrouping.ParentId;
     this.Path           = CustomerGrouping.Path;
     this.Level          = CustomerGrouping.Level;
     this.StatusId       = CustomerGrouping.StatusId;
     this.Description    = CustomerGrouping.Description;
     this.CustomerType   = CustomerGrouping.CustomerType == null ? null : new CustomerGrouping_CustomerTypeDTO(CustomerGrouping.CustomerType);
     this.Parent         = CustomerGrouping.Parent == null ? null : new CustomerGrouping_CustomerGroupingDTO(CustomerGrouping.Parent);
     this.Status         = CustomerGrouping.Status == null ? null : new CustomerGrouping_StatusDTO(CustomerGrouping.Status);
     this.CreatedAt      = CustomerGrouping.CreatedAt;
     this.UpdatedAt      = CustomerGrouping.UpdatedAt;
     this.Errors         = CustomerGrouping.Errors;
 }
Esempio n. 19
0
        public async Task <ActionResult <CustomerGrouping_CustomerGroupingDTO> > Get([FromBody] CustomerGrouping_CustomerGroupingDTO CustomerGrouping_CustomerGroupingDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            if (!await HasPermission(CustomerGrouping_CustomerGroupingDTO.Id))
            {
                return(Forbid());
            }

            CustomerGrouping CustomerGrouping = await CustomerGroupingService.Get(CustomerGrouping_CustomerGroupingDTO.Id);

            return(new CustomerGrouping_CustomerGroupingDTO(CustomerGrouping));
        }
Esempio n. 20
0
        public async Task <bool> ValidateId(CustomerGrouping CustomerGrouping)
        {
            CustomerGroupingFilter CustomerGroupingFilter = new CustomerGroupingFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = CustomerGrouping.Id
                },
                Selects = CustomerGroupingSelect.Id
            };

            int count = await UOW.CustomerGroupingRepository.Count(CustomerGroupingFilter);

            if (count == 0)
            {
                CustomerGrouping.AddError(nameof(CustomerGroupingValidator), nameof(CustomerGrouping.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
Esempio n. 21
0
        public async Task <CustomerGrouping> Delete(CustomerGrouping CustomerGrouping)
        {
            if (!await CustomerGroupingValidator.Delete(CustomerGrouping))
            {
                return(CustomerGrouping);
            }

            try
            {
                await UOW.CustomerGroupingRepository.Delete(CustomerGrouping);

                await Logging.CreateAuditLog(new { }, CustomerGrouping, nameof(CustomerGroupingService));

                return(CustomerGrouping);
            }
            catch (Exception ex)
            {
                await Logging.CreateSystemLog(ex, nameof(CustomerGroupingService));
            }
            return(null);
        }
Esempio n. 22
0
        public async Task <ActionResult <CustomerGroupingDetail_CustomerGroupingDTO> > Delete([FromBody] CustomerGroupingDetail_CustomerGroupingDTO CustomerGroupingDetail_CustomerGroupingDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new MessageException(ModelState);
            }

            CustomerGrouping CustomerGrouping = ConvertDTOToEntity(CustomerGroupingDetail_CustomerGroupingDTO);

            CustomerGrouping = await CustomerGroupingService.Delete(CustomerGrouping);

            CustomerGroupingDetail_CustomerGroupingDTO = new CustomerGroupingDetail_CustomerGroupingDTO(CustomerGrouping);
            if (CustomerGrouping.IsValidated)
            {
                return(CustomerGroupingDetail_CustomerGroupingDTO);
            }
            else
            {
                return(BadRequest(CustomerGroupingDetail_CustomerGroupingDTO));
            }
        }
Esempio n. 23
0
        private CustomerGrouping ConvertDTOToEntity(CustomerGrouping_CustomerGroupingDTO CustomerGrouping_CustomerGroupingDTO)
        {
            CustomerGrouping CustomerGrouping = new CustomerGrouping();

            CustomerGrouping.Id             = CustomerGrouping_CustomerGroupingDTO.Id;
            CustomerGrouping.Code           = CustomerGrouping_CustomerGroupingDTO.Code;
            CustomerGrouping.Name           = CustomerGrouping_CustomerGroupingDTO.Name;
            CustomerGrouping.CustomerTypeId = CustomerGrouping_CustomerGroupingDTO.CustomerTypeId;
            CustomerGrouping.ParentId       = CustomerGrouping_CustomerGroupingDTO.ParentId;
            CustomerGrouping.Path           = CustomerGrouping_CustomerGroupingDTO.Path;
            CustomerGrouping.Level          = CustomerGrouping_CustomerGroupingDTO.Level;
            CustomerGrouping.StatusId       = CustomerGrouping_CustomerGroupingDTO.StatusId;
            CustomerGrouping.Description    = CustomerGrouping_CustomerGroupingDTO.Description;
            CustomerGrouping.CustomerType   = CustomerGrouping_CustomerGroupingDTO.CustomerType == null ? null : new CustomerType
            {
                Id   = CustomerGrouping_CustomerGroupingDTO.CustomerType.Id,
                Code = CustomerGrouping_CustomerGroupingDTO.CustomerType.Code,
                Name = CustomerGrouping_CustomerGroupingDTO.CustomerType.Name,
            };
            CustomerGrouping.Parent = CustomerGrouping_CustomerGroupingDTO.Parent == null ? null : new CustomerGrouping
            {
                Id             = CustomerGrouping_CustomerGroupingDTO.Parent.Id,
                Code           = CustomerGrouping_CustomerGroupingDTO.Parent.Code,
                Name           = CustomerGrouping_CustomerGroupingDTO.Parent.Name,
                CustomerTypeId = CustomerGrouping_CustomerGroupingDTO.Parent.CustomerTypeId,
                ParentId       = CustomerGrouping_CustomerGroupingDTO.Parent.ParentId,
                Path           = CustomerGrouping_CustomerGroupingDTO.Parent.Path,
                Level          = CustomerGrouping_CustomerGroupingDTO.Parent.Level,
                StatusId       = CustomerGrouping_CustomerGroupingDTO.Parent.StatusId,
                Description    = CustomerGrouping_CustomerGroupingDTO.Parent.Description,
            };
            CustomerGrouping.Status = CustomerGrouping_CustomerGroupingDTO.Status == null ? null : new Status
            {
                Id   = CustomerGrouping_CustomerGroupingDTO.Status.Id,
                Code = CustomerGrouping_CustomerGroupingDTO.Status.Code,
                Name = CustomerGrouping_CustomerGroupingDTO.Status.Name,
            };
            CustomerGrouping.BaseLanguage = CurrentContext.Language;
            return(CustomerGrouping);
        }
Esempio n. 24
0
        public async Task <CustomerGrouping> Update(CustomerGrouping CustomerGrouping)
        {
            if (!await CustomerGroupingValidator.Update(CustomerGrouping))
            {
                return(CustomerGrouping);
            }
            try
            {
                var oldData = await UOW.CustomerGroupingRepository.Get(CustomerGrouping.Id);

                await UOW.CustomerGroupingRepository.Update(CustomerGrouping);

                CustomerGrouping = await UOW.CustomerGroupingRepository.Get(CustomerGrouping.Id);

                await Logging.CreateAuditLog(CustomerGrouping, oldData, nameof(CustomerGroupingService));

                return(CustomerGrouping);
            }
            catch (Exception ex)
            {
                await Logging.CreateSystemLog(ex, nameof(CustomerGroupingService));
            }
            return(null);
        }
Esempio n. 25
0
        public async Task <ActionResult> Import(IFormFile file)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }
            CustomerTypeFilter CustomerTypeFilter = new CustomerTypeFilter
            {
                Skip    = 0,
                Take    = int.MaxValue,
                Selects = CustomerTypeSelect.ALL
            };
            List <CustomerType> CustomerTypes = await CustomerTypeService.List(CustomerTypeFilter);

            StatusFilter StatusFilter = new StatusFilter
            {
                Skip    = 0,
                Take    = int.MaxValue,
                Selects = StatusSelect.ALL
            };
            List <Status> Statuses = await StatusService.List(StatusFilter);

            List <CustomerGrouping> CustomerGroupings = new List <CustomerGrouping>();

            using (ExcelPackage excelPackage = new ExcelPackage(file.OpenReadStream()))
            {
                ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.FirstOrDefault();
                if (worksheet == null)
                {
                    return(Ok(CustomerGroupings));
                }
                int StartColumn          = 1;
                int StartRow             = 1;
                int IdColumn             = 0 + StartColumn;
                int CodeColumn           = 1 + StartColumn;
                int NameColumn           = 2 + StartColumn;
                int CustomerTypeIdColumn = 3 + StartColumn;
                int ParentIdColumn       = 4 + StartColumn;
                int PathColumn           = 5 + StartColumn;
                int LevelColumn          = 6 + StartColumn;
                int StatusIdColumn       = 7 + StartColumn;
                int DescriptionColumn    = 8 + 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 NameValue           = worksheet.Cells[i + StartRow, NameColumn].Value?.ToString();
                    string CustomerTypeIdValue = worksheet.Cells[i + StartRow, CustomerTypeIdColumn].Value?.ToString();
                    string ParentIdValue       = worksheet.Cells[i + StartRow, ParentIdColumn].Value?.ToString();
                    string PathValue           = worksheet.Cells[i + StartRow, PathColumn].Value?.ToString();
                    string LevelValue          = worksheet.Cells[i + StartRow, LevelColumn].Value?.ToString();
                    string StatusIdValue       = worksheet.Cells[i + StartRow, StatusIdColumn].Value?.ToString();
                    string DescriptionValue    = worksheet.Cells[i + StartRow, DescriptionColumn].Value?.ToString();

                    CustomerGrouping CustomerGrouping = new CustomerGrouping();
                    CustomerGrouping.Code        = CodeValue;
                    CustomerGrouping.Name        = NameValue;
                    CustomerGrouping.Path        = PathValue;
                    CustomerGrouping.Level       = long.TryParse(LevelValue, out long Level) ? Level : 0;
                    CustomerGrouping.Description = DescriptionValue;
                    CustomerType CustomerType = CustomerTypes.Where(x => x.Id.ToString() == CustomerTypeIdValue).FirstOrDefault();
                    CustomerGrouping.CustomerTypeId = CustomerType == null ? 0 : CustomerType.Id;
                    CustomerGrouping.CustomerType   = CustomerType;
                    Status Status = Statuses.Where(x => x.Id.ToString() == StatusIdValue).FirstOrDefault();
                    CustomerGrouping.StatusId = Status == null ? 0 : Status.Id;
                    CustomerGrouping.Status   = Status;

                    CustomerGroupings.Add(CustomerGrouping);
                }
            }
            CustomerGroupings = await CustomerGroupingService.Import(CustomerGroupings);

            if (CustomerGroupings.All(x => x.IsValidated))
            {
                return(Ok(true));
            }
            else
            {
                List <string> Errors = new List <string>();
                for (int i = 0; i < CustomerGroupings.Count; i++)
                {
                    CustomerGrouping CustomerGrouping = CustomerGroupings[i];
                    if (!CustomerGrouping.IsValidated)
                    {
                        string Error = $"Dòng {i + 2} có lỗi:";
                        if (CustomerGrouping.Errors.ContainsKey(nameof(CustomerGrouping.Id)))
                        {
                            Error += CustomerGrouping.Errors[nameof(CustomerGrouping.Id)];
                        }
                        if (CustomerGrouping.Errors.ContainsKey(nameof(CustomerGrouping.Code)))
                        {
                            Error += CustomerGrouping.Errors[nameof(CustomerGrouping.Code)];
                        }
                        if (CustomerGrouping.Errors.ContainsKey(nameof(CustomerGrouping.Name)))
                        {
                            Error += CustomerGrouping.Errors[nameof(CustomerGrouping.Name)];
                        }
                        if (CustomerGrouping.Errors.ContainsKey(nameof(CustomerGrouping.CustomerTypeId)))
                        {
                            Error += CustomerGrouping.Errors[nameof(CustomerGrouping.CustomerTypeId)];
                        }
                        if (CustomerGrouping.Errors.ContainsKey(nameof(CustomerGrouping.ParentId)))
                        {
                            Error += CustomerGrouping.Errors[nameof(CustomerGrouping.ParentId)];
                        }
                        if (CustomerGrouping.Errors.ContainsKey(nameof(CustomerGrouping.Path)))
                        {
                            Error += CustomerGrouping.Errors[nameof(CustomerGrouping.Path)];
                        }
                        if (CustomerGrouping.Errors.ContainsKey(nameof(CustomerGrouping.Level)))
                        {
                            Error += CustomerGrouping.Errors[nameof(CustomerGrouping.Level)];
                        }
                        if (CustomerGrouping.Errors.ContainsKey(nameof(CustomerGrouping.StatusId)))
                        {
                            Error += CustomerGrouping.Errors[nameof(CustomerGrouping.StatusId)];
                        }
                        if (CustomerGrouping.Errors.ContainsKey(nameof(CustomerGrouping.Description)))
                        {
                            Error += CustomerGrouping.Errors[nameof(CustomerGrouping.Description)];
                        }
                        Errors.Add(Error);
                    }
                }
                return(BadRequest(Errors));
            }
        }
 private async Task SaveReference(CustomerGrouping CustomerGrouping)
 {
 }
Esempio n. 27
0
 public CustomerGroupingMaster_CustomerGroupingDTO(CustomerGrouping CustomerGrouping)
 {
     this.Id   = CustomerGrouping.Id;
     this.Name = CustomerGrouping.Name;
 }
Esempio n. 28
0
 public async Task <bool> Create(CustomerGrouping CustomerGrouping)
 {
     return(CustomerGrouping.IsValidated);
 }
 public CustomerGroupingDetail_CustomerGroupingDTO(CustomerGrouping CustomerGrouping)
 {
     this.Id   = CustomerGrouping.Id;
     this.Name = CustomerGrouping.Name;
 }