Ejemplo n.º 1
0
        /// <summary>
        /// updates a customer and order history in the database
        /// </summary>
        /// <param name="customer">customer object to update the database with</param>
        public void UpdateCustomer(Business.Customer customer)
        {
            Customers currentEntity = _context.Customers.Find(customer.Id);
            Customers newEntity     = Mapper.MapCustomerToOrders(customer);

            Log.Information("Updated cutomer {FirstName} {LastName}", customer.FirstName, customer.LastName);
            _context.Entry(currentEntity).CurrentValues.SetValues(newEntity);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// convert an object customer to an entity customer
 /// </summary>
 /// <param name="customer">customer object to be converted</param>
 /// <returns>customer entity</returns>
 public static Entities.Customers MapCustomerToOrders(Business.Customer customer)
 {
     return(new Entities.Customers
     {
         Id = customer.Id,
         FirstName = customer.FirstName,
         LastName = customer.LastName,
         TotalPurchases = customer.TotalPurchases,
         Orders = customer.Orders.Select(MapOrder).ToList(),
     });
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Handle one request.
        /// </summary>
        /// <param name="request">The request to handle.</param>
        /// <returns>A successful response.</returns>
        /// <remarks>If the method fails, it will throw an exception, corresponding to the failure types
        /// in http://xlentmatch.com/wiki/FailureResponse_Message#Error_Types</remarks>
        private static SuccessResponse HandleOne(Request request)
        {
            var response = new SuccessResponse(request);

            Business.Customer customer = null;
            try
            {
                customer = Business.Customer.Get(int.Parse(request.KeyValue));
            } catch (Exception)
            {
            }
            switch (request.RequestType)
            {
            case "Get":
                if (customer == null)
                {
                    throw new Xlent.Match.ClientUtilities.Exceptions.NotFoundException(request.ClientName, request.EntityName, request.KeyValue);
                }
                response.Data = new Data();
                Copy(customer.Model, response.Data);
                break;

            case "Update":
                if (customer == null)
                {
                    throw new Xlent.Match.ClientUtilities.Exceptions.NotFoundException(request.ClientName, request.EntityName, request.KeyValue);
                }
                Copy(request.Data, customer.Model);
                break;

            case "Create":
                if (customer != null)
                {
                    throw new Xlent.Match.ClientUtilities.Exceptions.MovedException(customer.Model.Id.ToString());
                }
                customer = Business.Customer.Create();
                Copy(request.Data, customer.Model);
                response.Key.Value = customer.Model.Id.ToString();
                break;

            default:
                throw new ArgumentOutOfRangeException("request", string.Format("Unknown request type: \"{0}\"", request.RequestType));
            }

            return(response);
        }
Ejemplo n.º 4
0
 internal Customer(Business.Customer i)
 {
     CustomerId = i.CustomerId;
     FirstName  = i.FirstName;
     LastName   = i.LastName;
 }
Ejemplo n.º 5
0
        public ActionResult CustomerProfile(string email)
        {
            List <ISAT.Web.ViewModel.CustomerProfile> list = new List <ViewModel.CustomerProfile>();

            if (!string.IsNullOrEmpty(email))
            {
                Business.Customer cust   = Business.Customer.GetCustomer(email);
                TicketInfo        ticket = TicketInfo.GetTicketInfo(cust.Email);
                if (cust != null)
                {
                    if (ticket != null)
                    {
                        var custList   = Business.CustomerInfoList.GetCustomerInfoList().Where(x => x.Email == ticket.Requester);
                        var openList   = ISAT.Business.TicketInfoList.GetOpenTicketByRequester(ticket.Requester).OrderByDescending(x => x.UpdatedDate);
                        var closedList = ISAT.Business.TicketInfoList.GetClosedTicketByRequester(ticket.Requester).OrderByDescending(x => x.UpdatedDate);

                        var newopenList = from c in openList
                                          select new CustomerProfile
                        {
                            TicketId    = c.idticket,
                            Subject     = c.TicketSubject,
                            Requester   = GetRequesterFullName(c.Requester),
                            CreatedDate = c.CreatedDate.ToString("dd MMM yyyy HH':'mm"),
                            UpdatedDate = c.UpdatedDate.ToString("dd MMM yyyy HH':'mm"),
                            Priority    = c.Priority,
                            TicketOwner = c.TicketOwner,
                            Status      = c.TicketStatus
                        };

                        var newcloseList = from c in closedList
                                           select new CustomerProfile
                        {
                            TicketId    = c.idticket,
                            Subject     = c.TicketSubject,
                            Requester   = GetRequesterFullName(c.Requester),
                            CreatedDate = c.CreatedDate.ToString("dd MMM yyyy HH':'mm"),
                            UpdatedDate = c.UpdatedDate.ToString("dd MMM yyyy HH':'mm"),
                            Priority    = c.Priority,
                            TicketOwner = c.TicketOwner,
                            Status      = c.TicketStatus,
                            CreatedBy   = c.CreatedBy
                        };

                        var newcustomerList = from c in custList
                                              select new CustomerProfile
                        {
                            FirstName   = c.FirstName,
                            LastName    = c.LastName,
                            Custno      = c.CustNo,
                            Email       = c.Email,
                            CompanyName = c.CompanyName,
                        };

                        list.AddRange(newcustomerList);
                        list.AddRange(newopenList);
                        list.AddRange(newcloseList);
                    }
                    return(View(list));
                }
                else
                {
                    ViewBag.Message = " Detail Not Found.";
                    return(RedirectToAction("IndexCustomer"));
                }
            }

            return(View());
        }