コード例 #1
0
        public async Task <IActionResult> Box()
        {
            Dictionary <string, string> listClient = new Dictionary <string, string>();

            foreach (var item in await _clientRepository.FIndAllsAsync(_employeeLogin.GetEmployee().BusinessId))
            {
                if (item is ClientJuridical)
                {
                    ClientJuridical client = (ClientJuridical)item;
                    listClient.Add(client.Id.ToString(), client.CompanyName);
                }
                else
                {
                    ClientPhysical client = (ClientPhysical)item;
                    listClient.Add(client.Id.ToString(), client.FullName);
                }
            }
            ViewBag.Client = listClient.Select(x => new SelectListItem(x.Value, x.Key));

            SalesOrder order = new SalesOrder
            {
                Client = await _clientRepository.QuickSaleAsync(_employeeLogin.GetEmployee().BusinessId)
            };

            return(View(order));
        }
コード例 #2
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            string cpf = value as string;

            if (!ValidationCpfOrCnpj.ValidationCpfOrCnpj.IsCpf(cpf))
            {
                return(new ValidationResult(Message.MSG_CPF_Invalido));
            }

            IClientRepository repository = (IClientRepository)validationContext.GetService(typeof(IClientRepository));
            EmployeeLogin     login      = (EmployeeLogin)validationContext.GetService(typeof(EmployeeLogin));

            List <ClientPhysical> list   = (List <ClientPhysical>)repository.FindByCpf(cpf, login.GetEmployee().BusinessId);
            ClientPhysical        client = (ClientPhysical)validationContext.ObjectInstance;

            if (list.Count > 1)
            {
                return(new ValidationResult(Message.MSG_CPF_Cadastrado));
            }

            if (list.Count == 1 && list[0].Id != client.Id)
            {
                return(new ValidationResult(Message.MSG_CPF_Cadastrado));
            }

            return(ValidationResult.Success);
        }
コード例 #3
0
        public async Task <IActionResult> FindByClient(string clientId)
        {
            Client Client = await _clientRepository.FindByIdAsync(int.Parse(clientId), _employeeLogin.GetEmployee().BusinessId);

            if (Client == null)
            {
                return(Json("Error"));
            }
            ClientJsonConsultBasic clientJson = new ClientJsonConsultBasic();

            clientJson.Id           = Client.Id.ToString();
            clientJson.Street       = Client.Address.Street;
            clientJson.Numero       = Client.Address.Number.ToString();
            clientJson.neighborhood = Client.Address.Neighborhood;
            clientJson.City         = Client.Address.City.Name;
            clientJson.State        = Client.Address.City.State.Name;
            clientJson.Email        = Client.Email;
            foreach (var item in Client.Contacts)
            {
                if (item.TypeNumber == Models.Enums.TypeNumber.Celular)
                {
                    clientJson.Phone = item.DDD + " - " + item.Number;
                }
            }
            if (Client is ClientJuridical)
            {
                ClientJuridical juridical = (ClientJuridical)Client;
                clientJson.Name = juridical.CompanyName;
            }
            else
            {
                ClientPhysical physical = (ClientPhysical)Client;
                clientJson.Name = physical.FullName;
            }

            return(Json(clientJson));
        }
コード例 #4
0
        public static string SheetsClient(List <Client> list, string path, string fileName)
        {
            try
            {
                using (var workbook = new XLWorkbook(path))
                {
                    var worksheet = workbook.Worksheets.Worksheet("Sheet1");
                    int i         = 0;
                    foreach (var obj in list)
                    {
                        if (i == 0)
                        {
                            worksheet.Cell("A" + (1 + i)).Value =
                                "Id";
                            worksheet.Cell("B" + (1 + i)).Value =
                                "InsertDate";
                            worksheet.Cell("C" + (1 + i)).Value =
                                "Nome";
                            worksheet.Cell("D" + (1 + i)).Value =
                                "Razão Social";
                            worksheet.Cell("E" + (1 + i)).Value =
                                "Nome Fantasia";
                            worksheet.Cell("F" + (1 + i)).Value =
                                "Celular";
                            worksheet.Cell("G" + (1 + i)).Value =
                                "Tel Res/Com";
                            worksheet.Cell("H" + (1 + i)).Value =
                                "Email";
                            worksheet.Cell("I" + (1 + i)).Value =
                                "Sexo";
                            worksheet.Cell("J" + (1 + i)).Value =
                                "Situação";
                            worksheet.Cell("K" + (1 + i)).Value =
                                "Nascimento";
                            worksheet.Cell("L" + (1 + i)).Value =
                                "Data de Abertura";
                            worksheet.Cell("M" + (1 + i)).Value =
                                "Funcionario Cadastro";
                            worksheet.Cell("N" + (1 + i)).Value =
                                "Cep";
                            worksheet.Cell("O" + (1 + i)).Value =
                                "Logradouro";
                            worksheet.Cell("P" + (1 + i)).Value =
                                "Número";
                            worksheet.Cell("Q" + (1 + i)).Value =
                                "Complemento";
                            worksheet.Cell("R" + (1 + i)).Value =
                                "Referencia";
                            worksheet.Cell("S" + (1 + i)).Value =
                                "Bairro";
                            worksheet.Cell("T" + (1 + i)).Value =
                                "Cidade";
                            worksheet.Cell("U" + (1 + i)).Value =
                                "Estado";
                        }
                        worksheet.Cell("A" + (2 + i)).Value =
                            obj.Id;
                        worksheet.Cell("B" + (2 + i)).Value =
                            obj.InsertDate;

                        if (obj is ClientPhysical)
                        {
                            ClientPhysical client = (ClientPhysical)obj;
                            worksheet.Cell("C" + (2 + i)).Value =
                                client.FullName;
                            worksheet.Cell("I" + (2 + i)).Value =
                                client.Sexo;
                            worksheet.Cell("K" + (2 + i)).Value =
                                client.BirthDay;
                        }
                        else
                        {
                            ClientJuridical client = (ClientJuridical)obj;
                            worksheet.Cell("D" + (2 + i)).Value =
                                client.CompanyName;
                            worksheet.Cell("E" + (2 + i)).Value =
                                client.FantasyName;
                            worksheet.Cell("L" + (2 + i)).Value =
                                client.OpeningDate;
                        }
                        foreach (var item in obj.Contacts)
                        {
                            if (item.TypeNumber == Models.Enums.TypeNumber.Celular)
                            {
                                worksheet.Cell("F" + (2 + i)).Value =
                                    item.DDD + " - " + item.Number;
                            }
                            if (item.TypeNumber == Models.Enums.TypeNumber.Residencial)
                            {
                                worksheet.Cell("G" + (2 + i)).Value =
                                    item.DDD + " - " + item.Number;
                            }
                        }
                        worksheet.Cell("H" + (2 + i)).Value =
                            obj.Email;
                        worksheet.Cell("J" + (2 + i)).Value =
                            obj.Active;
                        worksheet.Cell("M" + (2 + i)).Value =
                            obj.RegisterEmployee.Name;
                        worksheet.Cell("N" + (2 + i)).Value =
                            obj.Address.ZipCode;
                        worksheet.Cell("O" + (2 + i)).Value =
                            obj.Address.Street;
                        worksheet.Cell("P" + (2 + i)).Value =
                            obj.Address.Number;
                        worksheet.Cell("Q" + (2 + i)).Value =
                            obj.Address.Complement;
                        worksheet.Cell("R" + (2 + i)).Value =
                            obj.Address.Reference;
                        worksheet.Cell("S" + (2 + i)).Value =
                            obj.Address.Neighborhood;
                        worksheet.Cell("T" + (2 + i)).Value =
                            obj.Address.City.Name;
                        worksheet.Cell("U" + (2 + i)).Value =
                            obj.Address.City.State.Name;
                        i++;
                    }
                    workbook.Save();
                    return(Path.Combine("/ReportSheets_Temp/", fileName));
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }