Exemple #1
0
        public IHttpActionResult SubmitRequest(DataAccess.Entities.Request request)
        {
            bool          hasErrors = false;
            List <string> errorList = new List <string>();

            DataAccess.Infrastructure.Main main = null;

            try
            {
                main = Business.AppLogic.CreateRequest(request);
                if (main == null)
                {
                    hasErrors = true;
                    //errorList.Add($"Record Locator '{recordLocator}' Not Found");
                }
            }
            catch (Exception ex)
            {
                hasErrors = true;
                errorList.Add(ex.Message);
            }

            main.OrderDetails = null;
            main.User         = null;
            main.IpLocations  = null;

            return(Ok(new ViewModel.ApiMessage <DataAccess.Infrastructure.Main>
            {
                Data = main,
                HasErrors = hasErrors,
                ErrorList = errorList
            }));
        }
        public IHttpActionResult SubmitRequest(DataAccess.Entities.Request request)
        {
            bool          hasErrors = false;
            List <string> errorList = new List <string>();

            DataAccess.Infrastructure.Main main = null;

            try
            {
                //check for existing phone number / check if lead id already verified
                if (Business.AppLogic.PhoneNumberExists(request.Phone) ||
                    Business.AppLogic.LeadExists(request.Lead.LeadsId) ||
                    request.OrderDetails.Any(x => Business.AppLogic.AccountNumberExists(x.AccountNumber)))
                {
                    errorList.Add("This Order cannot be submitted as entered. A combination of this information is already in use.");
                    return(Ok(new ViewModel.ApiMessage <DataAccess.Infrastructure.Main>
                    {
                        Data = null,
                        HasErrors = true,
                        ErrorList = errorList
                    }));
                }

                //create request
                main = Business.AppLogic.CreateRequest(request);
                if (main == null)
                {
                    hasErrors = true;
                    errorList.Add($"Unable to save request.");
                }
            }
            catch (Exception ex)
            {
                hasErrors = true;
                errorList.Add(ex.Message);
            }

            main.OrderDetails = null;
            main.User         = null;
            main.IpLocations  = null;

            return(Ok(new ViewModel.ApiMessage <DataAccess.Infrastructure.Main>
            {
                Data = main,
                HasErrors = hasErrors,
                ErrorList = errorList
            }));
        }