コード例 #1
0
        public IActionResult OrderWithoutAccount(string name, string phoneNum, string email, string address)
        {
            int result = 0;

            if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(address) && phoneNum.Length > 8)
            {
                if (email.Contains("@") == false)
                {
                    return(Json(result));
                }

                InfoCustomer infoCustomer = new InfoCustomer()
                {
                    Name     = name,
                    PhoneNum = phoneNum,
                    Email    = email,
                    Address  = address
                };
                int createInfoResult = infoRepository.CreateInfoCustomer(infoCustomer);

                if (createInfoResult > 0)
                {
                    var order = new Order()
                    {
                        CreateAt       = DateTime.Today,
                        ShipperDate    = DateTime.Today.AddDays(3),
                        InfoCustomerId = infoCustomer.Id
                    };
                    orderRepository.CreateOrder(order);

                    var cart = HttpContext.Session.GetObjectFromJson <List <CartItem> >(CartSession);
                    foreach (var item in cart)
                    {
                        orderRepository.AddOrderDetailInOrder(order, item.ProductId, item.Amount);
                    }

                    result = orderRepository.GetOrderDetailsByOrderId(order.Id).Count;
                    if (result > 0)
                    {
                        HttpContext.Session.SetObjectAsJson(CartSession, new List <CartItem>());
                    }
                }
            }
            return(Json(result));
        }
        private async Task <InfoCustomer> GetInfoCustomerWithIdentityAndPhoneNumberIfHave(CheckInforCollectionDTO collectionInfo)
        {
            InfoCustomer inforCustomer = null;

            if (string.IsNullOrEmpty(collectionInfo.IdentityNumber)) // get lastest info customer and remove identity number, after that respone to client
            {
                inforCustomer = GetInfoCustomerQueryFilterByStatusActive().Where(x => x.CustomerPhone == collectionInfo.CustomerPhone).OrderByDescending(x => x.Id).FirstOrDefault();
            }
            else //get laster info customer by identity and phone number
            {
                inforCustomer = GetInfoCustomerQueryFilterByStatusActive().FirstOrDefault(x => x.CustomerPhone == collectionInfo.CustomerPhone && x.IdentityNumber == collectionInfo.IdentityNumber);
            }

            if (inforCustomer == null)
            {
                inforCustomer = await GetInfoCustomerFromPTI(collectionInfo);
            }

            return(inforCustomer);
        }
コード例 #3
0
        private void InactiveOldInfoCustomer(CollectionSheetRequestDTO sheet)
        {
            List <InfoCustomer> listInforCustomer = _infoCustomerRepository.FindAll()
                                                    .Where(x => sheet.InfoCustomer.CustomerPhone == x.CustomerPhone &&
                                                           sheet.InfoCustomer.IdentityNumber == x.IdentityNumber).ToList();

            listInforCustomer.ForEach(x =>
            {
                x.Status = Status.InActive;
                _infoCustomerRepository.Update(x);
            });
            if (!listInforCustomer.Select(x => x.Id).Contains(sheet.InfoCustomer.Id))
            {
                InfoCustomer infoCustomer = _infoCustomerRepository.FirstOrDefault(x => x.Id == sheet.InfoCustomerId);

                if (infoCustomer != null)
                {
                    infoCustomer.Status = Status.InActive;
                    _infoCustomerRepository.Update(infoCustomer);
                }
            }
        }
        private async Task <ConditionValidateDTO> ValidatePhoneAndIdentityWhenPLateNotFound(CheckInforCollectionDTO collectionInfo)
        {
            InfoCustomer infoCustomerByPhoneNumber = await GetInfoCustomerWithPhoneNumberIfHave(collectionInfo);

            InfoCustomer infoCustomerByIdentityNumber = await GetInfoCustomerWithIdentityNumberIfHave(collectionInfo);

            if (infoCustomerByIdentityNumber != null) // identity high priority
            {
                InfoCustomerDTO inforReturn = Mapper.Map <InfoCustomerDTO>(infoCustomerByIdentityNumber);
                SetStatusForCustomerInforReturn(collectionInfo, infoCustomerByIdentityNumber, inforReturn);
                return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOCUSTOMER, inforReturn));
            }

            if (infoCustomerByPhoneNumber != null) // after that is phone number
            {
                InfoCustomerDTO inforReturn = Mapper.Map <InfoCustomerDTO>(infoCustomerByPhoneNumber);
                SetStatusForCustomerInforReturn(collectionInfo, infoCustomerByPhoneNumber, inforReturn);
                return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOCUSTOMER, inforReturn));
            }

            return(new ConditionValidateDTO(StatusCondition.ACCEPT_NEW));
        }
コード例 #5
0
        InfoCustomer GetData()
        {
            InfoCustomer info  = new InfoCustomer();
            string       token = GetToken();

            var client = new RestClient(WebConfigurationManager.AppSettings["Url"]);

            client.Timeout = -1;
            var request = new RestRequest(Method.GET);

            request.AddHeader("Authorization", "Bearer " + token);
            //request.AddHeader("Cookie", "__cfduid=d62bc70a5f219096e34a7155514ce14f51617241370");
            IRestResponse response = client.Execute(request);

            //Console.WriteLine(response.Content);
            if (response.StatusCode == HttpStatusCode.OK)
            {
                JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
                info = jsonSerializer.Deserialize <InfoCustomer>(response.Content);
            }
            return(info);
        }
        private async Task <ConditionValidateDTO> ValidatePhoneAndIdentityWhenPLateFound(CarDTO carReturn, CheckInforCollectionDTO collectionInfo)
        {
            InfoCustomer infoCustomerByPhoneNumber = await GetInfoCustomerWithPhoneNumberIfHave(collectionInfo);

            InfoCustomer infoCustomerByIdentityNumber = await GetInfoCustomerWithIdentityNumberIfHave(collectionInfo);

            InfoCustomer infoCustomerByPhoneAndIdentity = await GetInfoCustomerWithIdentityAndPhoneNumberIfHave(collectionInfo);

            if (infoCustomerByPhoneNumber != null && infoCustomerByIdentityNumber != null)
            {
                if (infoCustomerByPhoneAndIdentity.TransactionCode == carReturn.TransactionCode &&
                    !string.IsNullOrEmpty(infoCustomerByPhoneAndIdentity.TransactionCode) && !string.IsNullOrEmpty(carReturn.TransactionCode))
                {
                    return(new ConditionValidateDTO(StatusCondition.DENIED));
                }
            }

            if (infoCustomerByIdentityNumber != null)
            {
                InfoCustomerDTO inforReturn = Mapper.Map <InfoCustomerDTO>(infoCustomerByIdentityNumber);
                SetStatusForCustomerInforReturn(collectionInfo, infoCustomerByIdentityNumber, inforReturn);
                return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOCUSTOMER_AND_CAR, inforReturn, carReturn));
            }

            if (infoCustomerByPhoneNumber != null)
            {
                InfoCustomerDTO inforReturn = Mapper.Map <InfoCustomerDTO>(infoCustomerByPhoneNumber);
                SetStatusForCustomerInforReturn(collectionInfo, infoCustomerByPhoneNumber, inforReturn);
                return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_INFOCUSTOMER_AND_CAR, inforReturn, carReturn));
            }

            if (infoCustomerByIdentityNumber == null && infoCustomerByPhoneNumber == null)
            {
                return(new ConditionValidateDTO(StatusCondition.ACCEPT_RE_NEW_BRIEF_CAR, null, carReturn));
            }

            return(new ConditionValidateDTO(StatusCondition.ACCEPT_NEW));
        }
コード例 #7
0
 public int CreateInfoCustomer(InfoCustomer infoCustomer)
 {
     context.Add(infoCustomer);
     return(context.SaveChanges());
 }
 private void SetStatusForCustomerInforReturn(CheckInforCollectionDTO collectionInfo, InfoCustomer inforCustomer, InfoCustomerDTO inforReturn)
 {
     if (inforCustomer.Id > 0)
     {
         inforReturn.IsGetDataFromPTI = false;
         inforReturn.IsGetDataFromIC  = true;
     }
     else
     {
         inforReturn.IsGetDataFromPTI = true;
         inforReturn.IsGetDataFromIC  = false;
     }
     if (string.IsNullOrEmpty(collectionInfo.IdentityNumber))
     {
         inforReturn.IdentityNumber = null;
     }
 }
コード例 #9
0
        public ActionResult GetFile()
        {
            XSSFWorkbook wb    = new XSSFWorkbook();
            ISheet       sheet = wb.CreateSheet("Archivo");

            #region Escribe Archivo
            int col_Actual = 0;
            int row_Actual = 0;
            var row_       = sheet.CreateRow(row_Actual++);
            row_.CreateCell(col_Actual).SetCellValue("IdCliente");
            col_Actual++;
            row_.CreateCell(col_Actual).SetCellValue("FechaRegistroEmpresa");
            col_Actual++;
            row_.CreateCell(col_Actual).SetCellValue("RazonSocial");
            col_Actual++;
            row_.CreateCell(col_Actual).SetCellValue("RFC");
            col_Actual++;
            row_.CreateCell(col_Actual).SetCellValue("Sucursal");
            col_Actual++;
            row_.CreateCell(col_Actual).SetCellValue("IdEmpleado");
            col_Actual++;
            row_.CreateCell(col_Actual).SetCellValue("Nombre");
            col_Actual++;
            row_.CreateCell(col_Actual).SetCellValue("Paterno");
            col_Actual++;
            row_.CreateCell(col_Actual).SetCellValue("Materno");
            col_Actual++;
            row_.CreateCell(col_Actual).SetCellValue("IdViaje");
            col_Actual = 0;

            InfoCustomer info = GetData();
            if (info.Data != null && info.Data.Count > 0)
            {
                foreach (var elm in info.Data)
                {
                    var row_d = sheet.CreateRow(row_Actual++);
                    row_d.CreateCell(col_Actual).SetCellValue(elm.IdCliente.ToString().Trim());
                    col_Actual++;
                    row_d.CreateCell(col_Actual).SetCellValue(elm.FechaRegistroEmpresa.ToString().Trim());;
                    col_Actual++;
                    row_d.CreateCell(col_Actual).SetCellValue(elm.RazonSocial.Trim());
                    col_Actual++;
                    row_d.CreateCell(col_Actual).SetCellValue(elm.RFC.Trim());
                    col_Actual++;
                    row_d.CreateCell(col_Actual).SetCellValue(elm.Sucursal);
                    col_Actual++;
                    row_d.CreateCell(col_Actual).SetCellValue(elm.IdEmpleado.ToString());
                    col_Actual++;
                    row_d.CreateCell(col_Actual).SetCellValue(elm.Nombre);
                    col_Actual++;
                    row_d.CreateCell(col_Actual).SetCellValue(elm.Paterno);
                    col_Actual++;
                    row_d.CreateCell(col_Actual).SetCellValue(elm.Materno);
                    col_Actual++;
                    row_d.CreateCell(col_Actual).SetCellValue(elm.IdViaje.ToString());
                    col_Actual = 0;
                }
            }


            #endregion

            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            try
            {
                wb.Write(bos);
            }
            finally
            {
                bos.Close();
            }
            byte[] bytes = bos.ToByteArray();

            string filename = "customers.xlsx";

            var cd = new System.Net.Mime.ContentDisposition
            {
                FileName = filename,
                Inline   = true,
            };

            Response.AppendHeader("Content-Disposition", cd.ToString());

            return(File(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
        }