public void EnsureValidDataTest() { var departmentRequest = new DepartmentRequest { DisplayOrder = 2, Module = DepartmentModule.LiveChat, ParentDepartmentId = 2, Title = "Title", Type = DepartmentType.Private, UserGroups = new List <int>(), UserVisibilityCustom = false }; Assert.DoesNotThrow(() => departmentRequest.EnsureValidData(RequestTypes.Create)); Assert.DoesNotThrow(() => departmentRequest.EnsureValidData(RequestTypes.Update)); }
private static RequestBodyBuilder PopulateRequestParameters(DepartmentRequest dept, RequestTypes requestType) { dept.EnsureValidData(requestType); RequestBodyBuilder parameters = new RequestBodyBuilder(); if (!String.IsNullOrEmpty(dept.Title)) { parameters.AppendRequestData("title", dept.Title); } parameters.AppendRequestData("type", EnumUtility.ToApiString(dept.Type)); if (requestType == RequestTypes.Create) { parameters.AppendRequestData("module", EnumUtility.ToApiString(dept.Module)); } if (dept.DisplayOrder > 0) { parameters.AppendRequestData("displayorder", dept.DisplayOrder); } if (dept.ParentDepartmentId > 0) { parameters.AppendRequestData("parentdepartmentid", dept.ParentDepartmentId); } if (dept.UserVisibilityCustom) { parameters.AppendRequestData("uservisibilitycustom", 1); } else { parameters.AppendRequestData("uservisibilitycustom", 0); } if (dept.UserGroups != null && dept.UserGroups.Count > 0) { parameters.AppendRequestDataArray <int>("usergroupid[]", dept.UserGroups); } return(parameters); }