コード例 #1
0
        /// <summary>
        /// convert order term to view model
        /// </summary>
        /// <param name="orderTerm"></param>
        /// <returns></returns>
        public OrderTermViewModel ConvertToView(OrderTerm orderTerm)
        {
            OrderTermViewModel model = new OrderTermViewModel();

            model.OrderTermId           = orderTerm.OrderTermId;
            model.CustomerId            = orderTerm.CustomerId;
            model.OrderTermsDescription = (!string.IsNullOrEmpty(orderTerm.Description)) ? orderTerm.Description : "N/A";

            return(model);
        }
コード例 #2
0
        /// <summary>
        /// convert order term view model to domain
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public OrderTerm ConvertToDomain(OrderTermViewModel model)
        {
            OrderTerm orderTerm = new OrderTerm();

            orderTerm.OrderTermId = model.OrderTermId;
            orderTerm.CustomerId  = model.CustomerId;
            orderTerm.Description = model.OrderTermsDescription;

            return(orderTerm);
        }
コード例 #3
0
        /// <summary>
        /// get order term by id
        /// </summary>
        /// <param name="orderTermId"></param>
        /// <returns></returns>
        public OrderTerm GetOrderTerm(Guid orderTermId)
        {
            var orderTerm = new OrderTerm();

            try
            {
                orderTerm = _db.OrderTerm.FirstOrDefault(x => x.OrderTermId == orderTermId);
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Error getting order term: {0} ", ex.ToString());
            }

            return(orderTerm);
        }
コード例 #4
0
        /// <summary>
        /// get order terms by customer
        /// </summary>
        /// <param name="customerId"></param>
        /// <returns></returns>
        public OrderTerm GetOrderTermsByCustomer(string customerId)
        {
            var orderTerms = new OrderTerm();

            try
            {
                orderTerms = _db.OrderTerm.FirstOrDefault(x => x.CustomerId.Replace(" ", string.Empty).ToLower() == customerId.Replace(" ", string.Empty).ToLower());
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Error getting order term by customer: {0} ", ex.ToString());
            }

            return(orderTerms);
        }
コード例 #5
0
        /// <summary>
        /// convert order term to customer view model
        /// </summary>
        /// <param name="orderTerm"></param>
        /// <returns></returns>
        public CustomerViewModel ConvertToCustomerView(OrderTerm orderTerm)
        {
            CustomerViewModel model = new CustomerViewModel();

            var _customerDynamicsRepository = new CustomerDynamicsRepository();

            var dynamicsCustomer = _customerDynamicsRepository.GetCustomer(orderTerm.CustomerId);

            model.OrderTermId           = orderTerm.OrderTermId;
            model.CustomerId            = orderTerm.CustomerId;
            model.CustomerName          = (dynamicsCustomer != null && !string.IsNullOrEmpty(dynamicsCustomer.SHRTNAME)) ? dynamicsCustomer.SHRTNAME : "N/A";
            model.OrderTermsDescription = (!string.IsNullOrEmpty(orderTerm.Description)) ? orderTerm.Description : "N/A";

            if (_customerDynamicsRepository != null)
            {
                _customerDynamicsRepository.Dispose();
                _customerDynamicsRepository = null;
            }

            return(model);
        }
コード例 #6
0
        /// <summary>
        /// update order term
        /// </summary>
        /// <param name="orderTerm"></param>
        /// <returns></returns>
        public OperationResult UpdateOrderTerm(OrderTerm orderTerm)
        {
            var operationResult = new OperationResult();

            var existingTerms = GetOrderTerm(orderTerm.OrderTermId);

            if (existingTerms != null)
            {
                logger.Debug("order terms are being updated.");

                try
                {
                    _db.OrderTerm.Attach(existingTerms);

                    _db.Entry(existingTerms).CurrentValues.SetValues(orderTerm);

                    _db.SaveChanges();

                    operationResult.Success = true;
                    operationResult.Message = "Success";
                }
                catch (Exception ex)
                {
                    operationResult.Success = false;
                    operationResult.Message = "Error";
                    logger.ErrorFormat("Error updating order term: {0} ", ex.ToString());
                }
            }
            else
            {
                operationResult.Success = false;
                operationResult.Message = "Unable to find selected order terms.";
            }

            return(operationResult);
        }
コード例 #7
0
 public OrderNode(FilterNode node, OrderTerm term)
 {
     this.filterNode = node;
     this.term       = term;
 }