public IActionResult LoadCustomerType(long?customerID, long?LangID)
        {
            GetCustomerTypes getCustomerType = new GetCustomerTypes();

            getCustomerType.CustomerID = customerID;
            if (LangID.HasValue)
            {
                getCustomerType.LangID = LangID;
            }
            else
            {
                getCustomerType.LangID = 1;
            }
            var result = getCustomerType.QueryAsync().Result;

            if (result is ValidationsOutput)
            {
                return(Ok(new ApiResult <List <ValidationItem> >()
                {
                    Data = ((ValidationsOutput)result).Errors
                }));
            }
            else
            {
                return(Ok((List <CustomerType>)result));
            }
        }
Exemplo n.º 2
0
        public IApiResult Create(CreateShare operation)
        {
            // check if the customer has type if not add it then add it on share
            // check if the document contain more than one policy holder ben then allow update share type
            GetCustomerTypes customerTypes = new GetCustomerTypes();

            customerTypes.CustomerID = operation.CustomerId;
            var typesResult = customerTypes.QueryAsync().Result;
            var types       = (List <CustomerType>)typesResult;
            int index       = types.FindIndex(item => item.LocCustomerType == operation.LocShareType);

            if (index >= 0)
            {
                var result = operation.ExecuteAsync().Result;
                if (result is ValidationsOutput)
                {
                    return(new ApiResult <List <ValidationItem> >()
                    {
                        Data = ((ValidationsOutput)result).Errors
                    });
                }
                else
                {
                    return(new ApiResult <object>()
                    {
                        Status = ApiResult <object> .ApiStatus.Success, ID = ((ComplateOperation <int>)result).ID.Value
                    });
                }
            }
            else
            {
                CustomerType policyHolder = new CustomerType();

                policyHolder.CustomerID      = operation.CustomerId;
                policyHolder.LocCustomerType = operation.LocShareType;
                policyHolder.CreatedBy       = operation.CreatedBy;
                policyHolder.CreationDate    = operation.CreationDate;
                // insert customer as policy holder
                var policyHolderResult = AddUpdateCustomerContacts.AddUpdateMode(policyHolder);
                var result             = operation.ExecuteAsync().Result;
                if (result is ValidationsOutput)
                {
                    return(new ApiResult <List <ValidationItem> >()
                    {
                        Data = ((ValidationsOutput)result).Errors
                    });
                }
                else
                {
                    return(new ApiResult <object>()
                    {
                        Status = ApiResult <object> .ApiStatus.Success, ID = ((ComplateOperation <int>)result).ID.Value
                    });
                }
            }
        }