Podio API - Groupings are missing from Views in C# - podio

I am working with the Podio api in C# and "Groupings" is missing from the View and ViewCreateUpdateRequest model.
When I use the sandbox call the result includes the groupings. So I'm thinking it is missing in the C# nuget package. Is there another way to access groupings for both Get View and Update View?

Sadly they are not maintaining the SDK for C#, but you can download their code from https://github.com/podio/podio-dotnet and update the code yourself.
That's what I did, I change the following
ItemId data type from Integer to Long
Added Groupings in View (Below is my View looks like)
public class View
{
[JsonProperty("view_id")]
public string ViewId { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("created_on")]
public DateTime CreatedOn { get; set; }
[JsonProperty("sort_by")]
public string SortBy { get; set; }
[JsonProperty("sort_desc")]
public string SortDesc { get; set; }
[JsonProperty("filters")]
public JArray Filters { get; set; }
[JsonProperty("fields")]
public JObject Fields { get; set; }
[JsonProperty("groupings")]
public JObject Groupings { get; set; }
[JsonProperty("created_by")]
public ByLine CreatedBy { get; set; }
[JsonProperty("layout")]
public string Layout { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("rights")]
public string[] Rights { get; set; }
[JsonProperty("filter_id")]
public string FilterId { get; set; }
[JsonProperty("items")]
public int Items { get; set; }
}
Search for NuGet Package: Podio.Async by acl2

Related

The new ASP.NET Core 3.0 Json serializer is leaving out data

I'm porting a web application to ASP.NET Core 3, and after a bit of a battle, I'm almost at the finish line. Everything seems to work, but all of a sudden my JSON data returned from the api is missing some levels.
It seems the options.JsonSerializerOptions.MaxDepth is default at 64 levels, so it can be that. Some other places where an option can be playing tricks on me?
This is the code (and a quickview of the value):
And this is the JSON I get in the browser:
So the ParticipantGroups property/collection is completely missing in the generated output.
Any ideas where this happens?
EDIT:
I've added a repo on Github that showcases the issue. Standard ASP.NET Core 3.0 solution, created from the template, with a change to the result returned from the Weatherforecast controller:
https://github.com/steentottrup/systemtextjsonissue
For now I've gone back to using Newtonsoft.Json, with the Microsoft.AspNetCore.Mvc.NewtonsoftJson package. Then when I have some time, I'll try finding out what the solution is, without Newtonsoft.Json.
The problem seems to be an error in the new version 3.0. At least it seems like an error to me.
It seems System.Text.Json will convert the class mentioned in the hierarchy, not the actual class. So if you are using an abstract class in the hierarchy, you're in trouble. The second I removed the base class, and used the actual class I'm returning, the problem goes away it seems.
So this doesn't work:
public class SurveyReportResult {
public Guid Id { get; set; }
public String Name { get; set; }
public Int32 MemberCount { get; set; }
public IEnumerable<OrganisationalUnit> OrganisationalUnits { get; set; }
}
public abstract class OrganisationalUnit {
public Guid Id { get; set; }
public String Name { get; set; }
public Int32 MemberCount { get; set; }
}
public class OrganisationalUnitWithParticipantGroups : OrganisationalUnit {
public IEnumerable<ParticipantGroup> ParticipantGroups { get; set; }
}
public class ParticipantGroup {
public Guid Id { get; set; }
public String Name { get; set; }
public Int32 MemberCount { get; set; }
}
This will only return the properties of the OrganisationalUnit class, not the additional property of the OrganisationalUnitWithParticipantGroups.
This works:
public class SurveyReportResult {
public Guid Id { get; set; }
public String Name { get; set; }
public Int32 MemberCount { get; set; }
public IEnumerable<OrganisationalUnitWithParticipantGroups> OrganisationalUnits { get; set; }
}
public class OrganisationalUnitWithParticipantGroups /*: OrganisationalUnit*/ {
public Guid Id { get; set; }
public String Name { get; set; }
public Int32 MemberCount { get; set; }
public IEnumerable<ParticipantGroup> ParticipantGroups { get; set; }
}
public class ParticipantGroup {
public Guid Id { get; set; }
public String Name { get; set; }
public Int32 MemberCount { get; set; }
}

How do I extend IdentityUser class in DbFirst approach?

I have a table named User in my database. I also have a .net core project where authentication is built-in. I want to connect to my database and after scaffolding reveals my User class, I want it to inherit from IdentityUser.
After scaffolding went well, I tried to inherit from IdentityUser.
public partial class User :IdentityUser<int>
{
public int Id { get; set; }
public string Country { get; set; }
public string PersonalId { get; set; }
public string MobilePhone { get; set; }
public string Email { get; set; }
public DateTime BirthDate { get; set; }
public string Password { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public byte[] Idimage { get; set; }
public bool? EmailConfirmed { get; set; }
public bool? Smsconfirmed { get; set; }
}
I can not see Identity Fields like PasswordHash, PhoneNumberConfirmed and so on, in my database. Specifically, in User table.

Using Complex DataType in EF CodeFirst

this is my Model :
public class Course
{
public int Id { get; set; }
public string Title { get; set; }
public string Institute { get; set; }
public string Instructor { get; set; }
public string Duration { get; set; }
public Level Level { get; set; }
public Format Format { get; set; }
public DateTime Released { get; set; }
public string FileSize { get; set; }
public string Desciption { get; set; }
}
public enum Level
{
Beginner,
Intermediate,
Advanced
}
public enum Format
{
Avi,
Hd,
FullHd
}
public class CourseDb:DbContext
{
public DbSet<Course> Courses { get; set; }
}
when I want to Create my new Controller with Scoffolding Using EF Template,
It's not create both Level and Format fields while I am using EF5
what's my problem?
Thanks in your advise
Enum types are currently not supported when scaffolding, which is most likely why the fields are not created.
My advice would be to use a helper method such as : Working with enums in ASP.NET MVC 3
and code it manually.
Update:
Looks like there is ticket logged for the support it here: http://mvcscaffolding.codeplex.com/workitem/10

Handling document relationships with T[] instead of T using RavenDB

RavenDB docs show how to deal with document relationships in this sample using Includes.
public class Order
{
public Product[] Items { get; set; }
public string CustomerId { get; set; }
public double TotalPrice { get; set; }
}
public class Product
{
public string Id { get; set; }
public string Name { get; set; }
public string[] Images { get; set; }
public double Price { get; set; }
}
public class Customer
{
public string Name { get; set; }
public string Address { get; set; }
public short Age { get; set; }
public string HashedPassword { get; set; }
}
How would I deal with Includes or Live Projections if I don't want to include the customer using Includes/Live Projections but a list of products instead:
public class Order
{
public string[] ItemIds { get; set; }
public string CustomerId { get; set; }
public double TotalPrice { get; set; }
}
If I understand what you're asking, this should help. I blogged about it here:
http://inaspiralarray.blogspot.com/2012/03/keeping-domain-model-pure-with-ravendb.html
Does that help?

How to add a couple of million documents to RavenDB - Embedded

I have installed the latest embedded binaries from NuGet and am using this code to store a 'product' poco. After a bit, the process dies with an OutOfMemoryException. Is storing this much data out of scope for Raven?
Thank you.
Stephen
var store = new EmbeddableDocumentStore { DataDirectory = #"C:\temp\ravendata", UseEmbeddedHttpServer = true };
store.Initialize();
using (var session = store.OpenSession())
{
foreach (var item in Parsers.GetProducts().ToList())
{
session.Store(item);
}
session.SaveChanges();
//var rdbList = session.Query<Product>().ToList();
}
[Serializable]
public class Product
{
public decimal ProductId { get; set; }
public string ItemNum { get; set; }
public string ProductName { get; set; }
public string BrandName { get; set; }
public string UOM { get; set; }
public string AveWeight { get; set; }
public string CasePack { get; set; }
public string PackageRemarks { get; set; }
public decimal Price { get; set; }
public string SupplierName { get; set; }
public string Url { get; set; }
public bool IsSpecialOrderItem { get; set; }
public bool IsSpecialPriceItem { get; set; }
public bool IsRebateItem { get; set; }
public bool IsTieredPricingItem { get; set; }
public bool IsOfflineSupplierItem { get; set; }
public string Catalog { get; set; }
public decimal CatalogId { get; set; }
public decimal CategoryId { get; set; }
public decimal PriceGroupId { get; set; }
public decimal OffineSupplierId { get; set; }
public string ManufactureName { get; set; }
public string ManufactureNum { get; set; }
public string Upc { get; set; }
public string Info { get; set; }
public string INFO2 { get; set; }
}
How big of a batch are you doing? It looks like people have success with 256 batch sizes. Seems like much more causes timeouts and memory exceptions.
*EDIT: It sounds like it is also recommended to make a new session per batch so as to not keep the session open too long which can cause timeout errors.
No, RavenDB is perfectly fine with this amount of data. Unless you don't RunInMemory an EmbeddedDocumentStore is pretty much the same as a standalone server, just without the http overhead and direct access to the database from the client.
Given your code, you want to make sure that you store your documents in batches, e.g. 1024 for each session. Another thing you want to make sure is, that your GetProducts() method returns an IEnumerable and yields the items in a proper ETL way of doing things.