/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { CreateUserGroupResponse response = new CreateUserGroupResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.IsStartElement) { if (context.TestExpression("CreateUserGroupResult", 2)) { UnmarshallResult(context, response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context); } } } return(response); }
public CreateUserGroupResponse Post(CreateUserGroupRequest request) { CreateUserGroupResponse resp; using (var con = this.TenantDbFactory.ObjectsDB.GetNewConnection()) { con.Open(); string sql = ""; if (request.Id > 0) { sql = @"UPDATE eb_usergroup SET name = @name,description = @description WHERE id = @id; INSERT INTO eb_user2usergroup(userid,groupid) SELECT uid,@id FROM UNNEST(array(SELECT unnest(@users) except SELECT UNNEST(array(SELECT userid from eb_user2usergroup WHERE groupid = @id AND eb_del = FALSE)))) as uid; UPDATE eb_user2usergroup SET eb_del = true WHERE userid IN( SELECT UNNEST(array(SELECT userid from eb_user2usergroup WHERE groupid = @id AND eb_del = FALSE)) except SELECT UNNEST(@users));"; } else { sql = @"INSERT INTO eb_usergroup (name,description) VALUES (@name,@description) RETURNING id; INSERT INTO eb_user2usergroup (userid,groupid) SELECT id, (CURRVAL('eb_usergroup_id_seq')) FROM UNNEST(@users) AS id"; } var cmd = this.TenantDbFactory.ObjectsDB.GetNewCommand(con, sql); int[] emptyarr = new int[] { }; cmd.Parameters.Add(this.TenantDbFactory.ObjectsDB.GetNewParameter("name", System.Data.DbType.String, request.Colvalues["groupname"])); cmd.Parameters.Add(this.TenantDbFactory.ObjectsDB.GetNewParameter("description", System.Data.DbType.String, request.Colvalues["description"])); cmd.Parameters.Add(this.TenantDbFactory.ObjectsDB.GetNewParameter("users", NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Integer, (request.Colvalues["userlist"].ToString() != string.Empty) ? request.Colvalues["userlist"].ToString().Split(',').Select(n => Convert.ToInt32(n)).ToArray() : emptyarr)); cmd.Parameters.Add(this.TenantDbFactory.ObjectsDB.GetNewParameter("id", System.Data.DbType.Int32, request.Id)); resp = new CreateUserGroupResponse { id = Convert.ToInt32(cmd.ExecuteScalar()) }; } return(resp); } //user group creation
public IActionResult UserGroups(int itemid) { var req = this.HttpContext.Request.Form; if (itemid > 0) { var fr = this.ServiceClient.Get <GetUserGroupResponse>(new GetUserGroupRequest { id = itemid, TenantAccountId = ViewBag.cid }); List <int> userlist = fr.Data.ContainsKey("userslist") ? fr.Data["userslist"].ToString().Replace("[", "").Replace("]", "").Split(',').Select(int.Parse).ToList() : new List <int>(); ViewBag.UGName = fr.Data["name"]; ViewBag.UGDescription = fr.Data["description"]; ViewBag.itemid = itemid; string html = ""; if (fr.Data.ContainsKey("userslist")) { foreach (var element in userlist) { html += "<div id ='@userid' class='alert alert-success columnDrag'>@users<button class='close' type='button' style='font-size: 15px;margin: 2px 0 0 4px;'>x</button></div>".Replace("@users", fr.Data[element.ToString()].ToString()).Replace("@userid", element.ToString()); } } ViewBag.UserList = html; } else { int groupid = string.IsNullOrEmpty(req["groupid"]) ? 0 : Convert.ToInt32(req["groupid"]); CreateUserGroupResponse res = this.ServiceClient.Post <CreateUserGroupResponse>(new CreateUserGroupRequest { Colvalues = req.ToDictionary(dict => dict.Key, dict => (object)dict.Value), Id = groupid }); } return(View()); }
public async Task <CreateUserGroupResponse> CreateUserGroup(CreateUserGroupRequest o) { var result = new CreateUserGroupResponse(o.RequestId); result.Application = o.Application; result.Id = await Server.CreateUserGroup(o.Application, o.Name, o.Description); return(result); }
public static CreateUserGroupResponse Unmarshall(UnmarshallerContext context) { CreateUserGroupResponse createUserGroupResponse = new CreateUserGroupResponse(); createUserGroupResponse.HttpResponse = context.HttpResponse; createUserGroupResponse.Code = context.StringValue("CreateUserGroup.Code"); createUserGroupResponse.Message = context.StringValue("CreateUserGroup.Message"); createUserGroupResponse.RequestId = context.StringValue("CreateUserGroup.RequestId"); CreateUserGroupResponse.CreateUserGroup_Data data = new CreateUserGroupResponse.CreateUserGroup_Data(); data.UserGroupName = context.StringValue("CreateUserGroup.Data.UserGroupName"); data.IsvSubId = context.StringValue("CreateUserGroup.Data.IsvSubId"); data.UserGroupId = context.LongValue("CreateUserGroup.Data.UserGroupId"); createUserGroupResponse.Data = data; return(createUserGroupResponse); }
public IResponseData <CreateUserGroupResponse> CreateUserGroup(CreateUserGroupRequest request) { IResponseData <CreateUserGroupResponse> response = new ResponseData <CreateUserGroupResponse>(); try { IUserGroupService userGroupService = IoC.Container.Resolve <IUserGroupService>(); CreateUserGroupResponse userGroupResponse = userGroupService.Create(request); response.SetData(userGroupResponse); } catch (ValidationException ex) { response.SetErrors(ex.Errors); response.SetStatus(System.Net.HttpStatusCode.PreconditionFailed); } return(response); }
private static void UnmarshallResult(XmlUnmarshallerContext context, CreateUserGroupResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 2; } while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("ARN", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.ARN = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Engine", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Engine = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("MinimumEngineVersion", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.MinimumEngineVersion = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("PendingChanges", targetDepth)) { var unmarshaller = UserGroupPendingChangesUnmarshaller.Instance; response.PendingChanges = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("ReplicationGroups/member", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.ReplicationGroups.Add(item); continue; } if (context.TestExpression("Status", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Status = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("UserGroupId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.UserGroupId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("UserIds/member", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.UserIds.Add(item); continue; } } } return; }