public static GenericResult AddContract(int resellerId, ContractAccount accountSettings) { try { ES.SecurityContext.SetThreadPrincipal(resellerId); // ES.TaskManager.StartTask(SystemTasks.SOURCE_ECOMMERCE, SystemTasks.TASK_ADD_CONTRACT); // GenericResult result = new GenericResult(); // int customerId = -1; int contractStatus = (int)ContractStatus.Pending; // if (accountSettings.PropertyExists(ContractAccount.CUSTOMER_ID)) { customerId = accountSettings.GetProperty<int>(ContractAccount.CUSTOMER_ID); // contractStatus = (int)ContractStatus.Active; } // Ensure customer not specified and then check requested username availability if (customerId == -1) { if (ES.UserController.UserExists(accountSettings[ContractAccount.USERNAME])) { result.Succeed = false; result.SetProperty("ResultCode", ES.BusinessErrorCodes.ERROR_USER_ALREADY_EXISTS); return result; } // EXIT } // string strNames = null; string strValues = null; // if (customerId == -1) { strNames = strValues = String.Empty; SecurityUtils.SerializeGenericProfile(ref strNames, ref strValues, accountSettings); } // emit the new contract string contractId = EcommerceProvider.AddContract(customerId, resellerId, accountSettings[ContractAccount.USERNAME], contractStatus, 0m, accountSettings[ContractAccount.FIRST_NAME], accountSettings[ContractAccount.LAST_NAME], accountSettings[ContractAccount.EMAIL], accountSettings[ContractAccount.COMPANY_NAME], strNames, strValues); // result.Succeed = true; result.SetProperty("ContractId", contractId); // Add contract object ES.TaskManager.TaskParameters[SystemTaskParams.PARAM_CONTRACT] = GetContract(contractId); // return result; } catch (Exception ex) { throw ES.TaskManager.WriteError(ex); } finally { ES.TaskManager.CompleteTask(); } }
public static GenericResult AddContract(int resellerId, ContractAccount accountSettings) { try { ES.SecurityContext.SetThreadPrincipal(resellerId); // ES.TaskManager.StartTask(SystemTasks.SOURCE_ECOMMERCE, SystemTasks.TASK_ADD_CONTRACT); // GenericResult result = new GenericResult(); // int customerId = -1; int contractStatus = (int)ContractStatus.Pending; // if (accountSettings.PropertyExists(ContractAccount.CUSTOMER_ID)) { customerId = accountSettings.GetProperty <int>(ContractAccount.CUSTOMER_ID); // contractStatus = (int)ContractStatus.Active; } // Ensure customer not specified and then check requested username availability if (customerId == -1) { if (ES.UserController.UserExists(accountSettings[ContractAccount.USERNAME])) { result.Succeed = false; result.SetProperty("ResultCode", ES.BusinessErrorCodes.ERROR_USER_ALREADY_EXISTS); return(result); } // EXIT } // string strNames = null; string strValues = null; // if (customerId == -1) { strNames = strValues = String.Empty; SecurityUtils.SerializeGenericProfile(ref strNames, ref strValues, accountSettings); } // emit the new contract string contractId = EcommerceProvider.AddContract(customerId, resellerId, accountSettings[ContractAccount.USERNAME], contractStatus, 0m, accountSettings[ContractAccount.FIRST_NAME], accountSettings[ContractAccount.LAST_NAME], accountSettings[ContractAccount.EMAIL], accountSettings[ContractAccount.COMPANY_NAME], strNames, strValues); // result.Succeed = true; result.SetProperty("ContractId", contractId); // Add contract object ES.TaskManager.TaskParameters[SystemTaskParams.PARAM_CONTRACT] = GetContract(contractId); // return(result); } catch (Exception ex) { throw ES.TaskManager.WriteError(ex); } finally { ES.TaskManager.CompleteTask(); } }