Ejemplo n.º 1
0
        public Shipping addShipping(Shipping item)
        {
            try
            {
                T_Shipping data = new T_Shipping()
                {
                    trackingCode  = item.trackingCode,
                    orderCode     = item.orderCode,
                    isActive      = item.isActive,
                    isShipping    = item.isShipping,
                    shippingDate  = item.shippingDate,
                    email         = item.email,
                    tel           = item.tel,
                    firstName     = item.firstName,
                    lastName      = item.lastName,
                    address       = item.address,
                    province      = item.province,
                    zipCode       = item.zipCode,
                    createDate    = DateTime.Now,
                    createBy      = item.createBy,
                    updateDate    = DateTime.Now,
                    updateBy      = item.updateBy,
                    printCoverQty = item.printCoverQty
                };

                return(ConvertToScreenModel.Transactions.shipping(dao.addShipping(data)));
            }
            catch (Exception ex)
            {
                JLog.write(LOG_TYPE.ERROR, LOG_POSITION.BO, this, JLog.GetCurrentMethod(), ex);
                return(null);
            }
        }
Ejemplo n.º 2
0
 public Order updateOrderHeader(T_Order item)
 {
     try
     {
         return(ConvertToScreenModel.Transactions.order(dao.updateOrderHeader(item)));
     }
     catch (Exception ex)
     {
         JLog.write(LOG_TYPE.ERROR, LOG_POSITION.BO, this, JLog.GetCurrentMethod(), ex);
         return(null);
     }
 }
Ejemplo n.º 3
0
 public bool deleteProduct(Product item)
 {
     try
     {
         this.dao.deleteProduct(item.id);
         return(true);
     }
     catch (Exception ex)
     {
         JLog.write(LOG_TYPE.ERROR, LOG_POSITION.BO, this, JLog.GetCurrentMethod(), ex);
         return(false);
     }
 }
Ejemplo n.º 4
0
 public bool deletePost(Post data)
 {
     try
     {
         dao.deletePost(data.id);
         return(true);
     }
     catch (Exception ex)
     {
         JLog.write(LOG_TYPE.ERROR, LOG_POSITION.BO, this, JLog.GetCurrentMethod(), ex);
         return(false);
     }
 }
Ejemplo n.º 5
0
        public Order addOrderHeader(Order item)
        {
            dao.beginTransaction();
            try
            {
                string code = "O" + DateTime.Now.ToString("yyyyMMdd");
                code += (_countOrderCode(code) + 1).ToString("00#");

                T_Order data = new T_Order()
                {
                    address           = item.address,
                    code              = code,
                    email             = item.email,
                    firstName         = item.firstName,
                    lastName          = item.lastName,
                    isPay             = item.isPay,
                    isShipping        = item.isShipping,
                    shippingDateStart = item.shippingDateStart,
                    shippingDateEnd   = item.shippingDateEnd,
                    shippingDate      = item.shippingDate,
                    orderDate         = item.orderDate,
                    payDate           = item.payDate,
                    province          = item.province,
                    shippingPrice     = item.shippingPrice,
                    tel               = item.tel,
                    totalPrice        = item.totalPrice,
                    totalProductPrice = item.totalProductPrice,
                    zipCode           = item.zipCode,
                    isActive          = item.isActive,
                    isCreateShipping  = item.isCreateShipping,
                    createBy          = item.createBy,
                    createDate        = DateTime.Now,
                    updateBy          = item.updateBy,
                    updateDate        = DateTime.Now,
                    isMeetReceive     = item.isMeetReceive
                };

                dao.addOrderHeader(data);
                dao.saveChange();
                dao.commit();
                return(ConvertToScreenModel.Transactions.order(data));
            }
            catch (Exception ex)
            {
                dao.rollback();
                JLog.write(LOG_TYPE.ERROR, LOG_POSITION.BO, this, JLog.GetCurrentMethod(), ex);
                return(null);
            }
        }
Ejemplo n.º 6
0
        public bool finishShipping(List <Shipping> datas)
        {
            try
            {
                List <int> ids = datas.Select(m => m.id).ToList();

                dao.finishShipping(ids);

                return(true);
            }
            catch (Exception ex)
            {
                JLog.write(LOG_TYPE.ERROR, LOG_POSITION.BO, this, JLog.GetCurrentMethod(), ex);
                return(false);
            }
        }
Ejemplo n.º 7
0
        public bool updateOrderActive(List <Order> datas)
        {
            try
            {
                foreach (var data in datas)
                {
                    dao.updateOrderActive(data.id, data.isActive);
                }

                return(true);
            }
            catch (Exception ex)
            {
                JLog.write(LOG_TYPE.ERROR, LOG_POSITION.BO, this, JLog.GetCurrentMethod(), ex);
                return(false);
            }
        }
Ejemplo n.º 8
0
        public bool finishOrders(List <Order> datas)
        {
            try
            {
                foreach (var d in datas)
                {
                    dao.finishOrder(d.id);
                }

                dao.saveChange();
                return(true);
            }
            catch (Exception ex)
            {
                JLog.write(LOG_TYPE.ERROR, LOG_POSITION.BO, this, JLog.GetCurrentMethod(), ex);
                return(false);
            }
        }
Ejemplo n.º 9
0
        public bool updateOrderPayment(ConfirmOrderPaymentScreenModel data)
        {
            try
            {
                var order = this.dao.getOrders().Where(m => m.code == data.orderCode).FirstOrDefault();
                if (order == null)
                {
                    return(false);
                }
                dao.makeOrderPay(data.orderCode, data.payment.paymentDate);

                if (order.isShipping == true)
                {
                    new ShippingBO().addShipping(new Shipping()
                    {
                        address       = order.address,
                        createBy      = data.userId,
                        createDate    = DateTime.Now,
                        email         = order.email,
                        firstName     = order.firstName,
                        isActive      = true,
                        isShipping    = false,
                        lastName      = order.lastName,
                        orderCode     = order.code,
                        printCoverQty = 0,
                        province      = order.province,
                        select        = false,
                        shippingDate  = null,
                        tel           = order.tel,
                        trackingCode  = "",
                        updateBy      = data.userId,
                        updateDate    = DateTime.Now,
                        zipCode       = order.zipCode
                    });
                }

                return(true);
            }
            catch (Exception ex)
            {
                JLog.write(LOG_TYPE.ERROR, LOG_POSITION.BO, this, JLog.GetCurrentMethod(), ex);
                return(false);
            }
        }
Ejemplo n.º 10
0
        public bool updatePostActiveFromList(List <Post> datas, bool isActive)
        {
            this.dao.beginTransaction();
            try
            {
                foreach (var d in datas)
                {
                    dao.updatePostActiveWithoutSaveChange(d.id, isActive);
                }

                dao.saveChange();
                dao.commit();
                return(true);
            }
            catch (Exception ex)
            {
                this.dao.rollback();
                JLog.write(LOG_TYPE.ERROR, LOG_POSITION.BO, this, JLog.GetCurrentMethod(), ex);
                return(false);
            }
        }
Ejemplo n.º 11
0
        public User addUser(User user, List <Role> roles)
        {
            dao.beginTransaction();
            try
            {
                S_User data = new S_User()
                {
                    createBy    = 0,
                    createDate  = DateTime.Now,
                    displayName = user.displayName,
                    email       = user.email,
                    isActive    = false,
                    password    = JEncode.HashPassword(user.password),
                    updateBy    = 0,
                    updateDate  = DateTime.Now
                };

                data = dao.addUser(data);
                dao.saveChange();

                S_RoleMapping map = new S_RoleMapping()
                {
                    role = Roles.SalmornUser, userId = data.userId
                };

                dao.addRoleMapping(map);

                dao.saveChange();
                dao.commit();

                return(ConvertToScreenModel.Systems.user(data));
            }
            catch (Exception ex)
            {
                dao.rollback();
                JLog.write(LOG_TYPE.ERROR, LOG_POSITION.BO, this, JLog.GetCurrentMethod(), ex);
                return(null);
            }
        }
Ejemplo n.º 12
0
        public List <ConfirmOrderPaymentScreenModel> getOrderForConfirmPayments(List <Order> datas)
        {
            try
            {
                PaymentNotificationDAO pdao = new PaymentNotificationDAO();
                List <ConfirmOrderPaymentScreenModel> results = new List <ConfirmOrderPaymentScreenModel>();
                var codes  = datas.Select(m => m.code).ToList();
                var orders = dao.getOrders().Where(m => codes.Contains(m.code)).ToList();

                foreach (var c in codes)
                {
                    var os = orders.Where(m => m.code == c).ToList();
                    ConfirmOrderPaymentScreenModel confirmPayment = new ConfirmOrderPaymentScreenModel();
                    if (confirmPayment == null)
                    {
                        continue;
                    }

                    confirmPayment.orders        = os.Select(m => ConvertToScreenModel.Transactions.order(m)).ToList();
                    confirmPayment.totalPrice    = os.Select(m => m.totalPrice).Sum();
                    confirmPayment.shippingPrice = os.Select(m => m.shippingPrice).Sum();
                    confirmPayment.productPrice  = os.Select(m => m.totalProductPrice).Sum();
                    confirmPayment.qty           = os.Select(m => m.qty).Sum();
                    confirmPayment.orderCode     = c;
                    confirmPayment.payment       = ConvertToScreenModel.Transactions.paymentNotification(pdao.getPaymentNotificationFromOrderCode(confirmPayment.orderCode));

                    results.Add(confirmPayment);
                }

                return(results);
            }
            catch (Exception ex)
            {
                JLog.write(LOG_TYPE.ERROR, LOG_POSITION.BO, this, JLog.GetCurrentMethod(), ex);
                return(null);
            }
        }
Ejemplo n.º 13
0
        public Product addProduct(Product item)
        {
            try
            {
                string code = "SLM" + DateTime.Now.ToString("yyyyMMdd");
                code += (_countProductCode(code) + 1).ToString("00#");

                M_Product data = new M_Product()
                {
                    code       = code,
                    cost       = item.cost,
                    createBy   = item.createBy,
                    createDate = DateTime.Now,
                    detail     = item.detail,
                    isActive   = item.isActive,
                    isPreOrder = item.isPreOrder,
                    isUseStock = item.isUseStock,
                    title      = item.title,
                    name       = item.name,
                    note       = item.note,
                    preEnd     = item.preEnd,
                    preStart   = item.preStart,
                    price      = item.price,
                    qtyShippingPriceCeiling = item.qtyShippingPriceCeiling,
                    shippintPriceRate       = item.shippintPriceRate,
                    unitName       = item.unitName,
                    updateBy       = item.updateBy,
                    updateDate     = DateTime.Now,
                    weight         = item.weight,
                    isDelete       = item.isDelete,
                    isManualPickup = item.isManualPickup,
                    pickupAt       = item.pickupAt,
                    stockQrty      = item.stockQrty
                };

                foreach (var i in item.images)
                {
                    var image = new M_Product_Image()
                    {
                        fileId    = i.id,
                        productId = data.id
                    };

                    //image.L_FileUpload = new L_FileUpload()
                    //{
                    //    id = i.file.id,
                    //    fileName = i.file.fileName,
                    //    ipAddress = i.file.ipAddress,
                    //    macAddress = i.file.macAddress,
                    //    type = i.file.type,
                    //    uploadDate = i.file.uploadDate,
                    //    userId = i.file.userId
                    //};
                    data.M_Product_Image.Add(image);
                }

                return(ConvertToScreenModel.Masters.product(dao.addProduct(data)));
            }
            catch (Exception ex)
            {
                JLog.write(LOG_TYPE.ERROR, LOG_POSITION.BO, this, JLog.GetCurrentMethod(), ex);
                return(null);
            }
        }