Exemplo n.º 1
0
        /// <summary>
        /// A method to represent Customer object as a string.
        /// </summary>
        /// <param name="format">Concrete customer representation.</param>
        /// <returns>Customer representation.</returns>
        public string ToString(CustomerRepresentation format)
        {
            switch (format)
            {
            case CustomerRepresentation.NRC:
                return(string.Format(FormatHelper.RevenueFormat(), "Customer record: {0}, {1:C}, {2}", this.Name, this.Revenue, this.ContactPhone));

            case CustomerRepresentation.NrC:
                return(string.Format("Customer record: {0}, {1}, {2}", this.Name, this.Revenue, this.ContactPhone));

            case CustomerRepresentation.NC:
                return(string.Format("Customer record: {0}, {1}", this.Name, this.ContactPhone));

            case CustomerRepresentation.NR:
                return(string.Format(FormatHelper.RevenueFormat(), "Customer record: {0}, {1:C}", this.Name, this.Revenue));

            case CustomerRepresentation.Nr:
                return(string.Format("Customer record: {0}, {1}", this.Name, this.Revenue));

            case CustomerRepresentation.N:
                return(string.Format("Customer record: {0}", this.Name));

            case CustomerRepresentation.RC:
                return(string.Format(FormatHelper.RevenueFormat(), "Customer record: {0:C}, {1}", this.Revenue, this.ContactPhone));

            case CustomerRepresentation.rC:
                return(string.Format("Customer record: {0}, {1}", this.Revenue, this.ContactPhone));

            case CustomerRepresentation.C:
                return(string.Format("Customer record: {0}", this.ContactPhone));

            case CustomerRepresentation.R:
                return(string.Format(FormatHelper.RevenueFormat(), "Customer record: {0:C}", this.Revenue));

            case CustomerRepresentation.r:
                return(string.Format("Customer record: {0}", this.Revenue));

            default:
                throw new ArgumentException();
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult <CustomerRepresentation> > CreateCustomer([FromBody] CustomerSpecification spec)
        {
            var customer = await this._customers.AddAsync(spec.Name);

            return(this.Ok(CustomerRepresentation.FromEntity(customer)));
        }
Exemplo n.º 3
0
 public string CustomerToString_Customer_StringRepresentation(CustomerRepresentation representation)
 {
     return(testCustomer.ToString(representation));
 }
Exemplo n.º 4
0
        public async Task <ActionResult <IEnumerable <CustomerRepresentation> > > FindCustomers()
        {
            var customers = await this._customers.QueryAsync(c => true);

            return(this.Ok(customers.Select(d => CustomerRepresentation.FromEntity(d))));
        }