private static void ValidateSpinnerData(SpinnerData data) { data.AngleMax.Should().Be(50.698f); data.AngleMin.Should().Be(-12.87f); data.Center.X.Should().Be(494f); data.Center.Y.Should().Be(1401.62f); data.Elasticity.Should().Be(0.6824f); data.Height.Should().Be(13.532f); data.Image.Should().Be(""); data.IsVisible.Should().Be(true); data.Length.Should().Be(124.31f); data.Material.Should().Be("Red"); data.Rotation.Should().Be(47.98f); data.ShowBracket.Should().Be(true); data.Surface.Should().Be(""); }
private static void ValidateSpinnerData(SpinnerData data) { Assert.Equal(50.698f, data.AngleMax); Assert.Equal(-12.87f, data.AngleMin); Assert.Equal(494f, data.Center.X); Assert.Equal(1401.62f, data.Center.Y); Assert.Equal(0.6824f, data.Elasticity); Assert.Equal(13.532f, data.Height); Assert.Equal("", data.Image); Assert.Equal(true, data.IsVisible); Assert.Equal(124.31f, data.Length); Assert.Equal("Red", data.Material); Assert.Equal(47.98f, data.Rotation); Assert.Equal(true, data.ShowBracket); Assert.Equal("", data.Surface); }
public ApiResponse <Object> GetPacketByUserId(ApiPacketRequest apr) { ApiResponse <Object> returnObject = new ApiResponse <Object>(); List <object> obj = new List <object>(); switch (apr.Command) { case "GetData": { if (apr.TableName == "SpinnerData") { var spinnerRequest = JsonConvert.DeserializeObject <SpinnerRequest>(apr.ApiPacket.Packet.ToString()); SpinnerData spinner = new SpinnerData(); var result = spinner.APIGetSpinnerData(QueryFromAPIPacketRequest(apr), spinnerRequest); obj.AddRange(result); returnObject = GetApiResponse(apr, obj, apr.TotalRecord != 0 ? spinner.APIGetTotalRecord(QueryFromAPIPacketRequest(apr), spinnerRequest) : apr.TotalRecord); break; } else { var dynamicModelType = Dynamic.GetObjectType(apr.TableName); var selectObj = Activator.CreateInstance(dynamicModelType); var data = JsonConvert.DeserializeObject <GetDataPacket>(apr.ApiPacket.Packet.ToString()); var result = Dynamic.DynamicSelectWithPaging(selectObj, data, apr.PageNo, apr.PageSize); obj.AddRange(result); returnObject = GetApiResponse(apr, obj, apr.TotalRecord != 0 ? Dynamic.DynamicSelectTotalRecortCount(selectObj, data) : apr.TotalRecord); break; } } default: { ApiResponse <object> response = new ApiResponse <object>() { Success = false, ApiPacket = null, PageNo = apr.PageNo, PageSize = apr.PageSize, TotalRecord = 0, Message = "Table is not registered to System", Status = 400 }; return(response); } } return(returnObject); }
public ApiResponse <Object> GetPacketByUserId(ApiPacketRequest apr) { ApiResponse <Object> returnObject = new ApiResponse <Object>(); List <object> obj = new List <object>(); switch (apr.TableName) { case "Login": { UsersLogin query = JsonConvert.DeserializeObject <UsersLogin>(apr.ApiPacket.Packet.ToString()); var result = new AspNetUsers().Login(query); ApiPacket <LoginResponse> fp = new ApiPacket <LoginResponse>() { Packet = new LoginResponse() }; if (result != null) { returnObject.ApiPacket.Packet = new LoginResponse() { UserInfo = result.UserInfo /*, BlockInfo = result.BlockInfo ServicePoint = result.ServicePoint, GeoLocation = result.GeoLocation*/ }; } ApiResponse <LoginResponse> response = new ApiResponse <LoginResponse>() { Success = result != null ? true : false, ApiPacket = fp, PageNo = apr.PageNo, PageSize = apr.PageSize, TotalRecord = 0, Message = result != null ? "Login successfully." : "Invalid Username or Password", Status = result != null ? 200 : 400 }; Tools.CopyClass(returnObject, response); break; //return returnObject; } case "UserGeo": { var result = new PermittedGeoLocation().GetPermittedGeoLocation(new PermittedGeoLocationRM { UserId = apr.UserId });; ApiPacket <PermittedGeoLocationViewModels> fp = new ApiPacket <PermittedGeoLocationViewModels>() { Packet = new PermittedGeoLocationViewModels() }; if (result != null) { returnObject.ApiPacket.Packet = new PermittedGeoLocationViewModels() { District = result.District, Upazila = result.Upazila, Unions = result.Unions, Village = result.Village, CenterInfo = result.CenterInfo, CampInfo = result.CampInfo }; } ApiResponse <PermittedGeoLocationViewModels> response = new ApiResponse <PermittedGeoLocationViewModels>() { Success = result != null ? true : false, ApiPacket = fp, PageNo = apr.PageNo, PageSize = apr.PageSize, TotalRecord = 0, Message = result != null ? "Record Fetched successfully." : "Record Fetched fail.", Status = result != null ? 200 : 400 }; Tools.CopyClass(returnObject, response); break; } case "UniqueId": { var requestObject = JsonConvert.DeserializeObject <RequestForUniqueId>(apr.ApiPacket.Packet.ToString()); var result = new UniqueId().SaveAndGet(requestObject ?? new RequestForUniqueId(), apr.UserId); returnObject = GetApiResponse(apr, result.ToList <object>(), result.Count); break; } case "SpinnerData": { var spinnerRequest = JsonConvert.DeserializeObject <SpinnerRequest>(apr.ApiPacket.Packet.ToString()); SpinnerData spinner = new SpinnerData(); var result = spinner.APIGetSpinnerData(QueryFromAPIPacketRequest(apr), spinnerRequest); obj.AddRange(result); returnObject = GetApiResponse(apr, obj, apr.TotalRecord != 0 ? spinner.APIGetTotalRecord(QueryFromAPIPacketRequest(apr), spinnerRequest) : apr.TotalRecord); break; } case "BlockInfo": { var requestObject = new ForApiResponse() { UserId = apr.UserId }; BlockInfo blockinfo = new BlockInfo(); var result = blockinfo.APIGetBlockList(requestObject); obj.AddRange(result); returnObject = GetApiResponse(apr, result.ToList <object>(), result.Count); break; } default: { ApiResponse <object> response = new ApiResponse <object>() { Success = false, ApiPacket = null, PageNo = apr.PageNo, PageSize = apr.PageSize, TotalRecord = 0, Message = "Table is not registered to System", Status = 400 }; return(response); } } return(returnObject); }