|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NorthwindViewModel;
using NorthwindDataModel;
using NorthwindDataAccessServices;
using NorthwindBusinessServices;
namespace NorthwindApplicationServices
{
public class CustomerApplicationService
{
/// <summary>
/// Customer Inquiry
/// </summary>
/// <param name="viewModel"></param>
/// <returns></returns>
public CustomerViewModel CustomerInquiry(CustomerViewModel viewModel)
{
int totalCustomers;
List<String> returnMessage = new List<String>();
CustomerDataAccessService customerDataAccessService = new CustomerDataAccessService();
try
{
List<Customer> customers = customerDataAccessService.CustomerInquiry(viewModel.Customer,
viewModel.CurrentPageNumber, viewModel.SortExpression, viewModel.SortDirection,
viewModel.PageSize, out totalCustomers);
viewModel.TotalCustomers = totalCustomers;
viewModel.TotalPages = Utilities.CalculateTotalPages(totalCustomers, viewModel.PageSize);
viewModel.Customers = customers;
if (viewModel.TotalCustomers > 0 && viewModel.TotalPages < viewModel.CurrentPageNumber)
{
returnMessage.Add("Please resubmit your request.");
viewModel.ReturnMessage = returnMessage;
viewModel.ReturnStatus = false;
}
else
{
returnMessage.Add(totalCustomers.ToString() + " customers found.");
viewModel.ReturnMessage = returnMessage;
viewModel.ReturnStatus = true;
}
}
catch (Exception e)
{
returnMessage.Add("An application error has occurred. Please call technical support.");
viewModel.ReturnStatus = false;
}
viewModel.ReturnMessage = returnMessage;
return viewModel;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Mark Caplin has specialized in Information Technology solutions for the past 30 years. Specializing in full life-cycle development projects for both enterprise-wide systems and Internet/Intranet based solutions.
For the past fifteen years, Mark has specialized in the Microsoft .NET framework using C# as his tool of choice. For the past four years Mark has been implementing Single Page Applications using the Angular platform.
When not coding, Mark enjoys playing tennis, listening to U2 music, watching Miami Dolphins football and watching movies in Blu-Ray technology.
In between all this, his wife of over 25 years, feeds him well with some great home cooked meals.
You can contact Mark at mark.caplin@gmail.com
...