/// <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(); } }
public async Task <ActionResult <CustomerRepresentation> > CreateCustomer([FromBody] CustomerSpecification spec) { var customer = await this._customers.AddAsync(spec.Name); return(this.Ok(CustomerRepresentation.FromEntity(customer))); }
public string CustomerToString_Customer_StringRepresentation(CustomerRepresentation representation) { return(testCustomer.ToString(representation)); }
public async Task <ActionResult <IEnumerable <CustomerRepresentation> > > FindCustomers() { var customers = await this._customers.QueryAsync(c => true); return(this.Ok(customers.Select(d => CustomerRepresentation.FromEntity(d)))); }