How to show a file in a Details view in asp.NET MVC4 web application? - asp.net-mvc-4

I am working on an asp.NET MVC4 web application. I have a create view with Upload file (CV). I succeeded to upload the file correctly but I need to show it (the CV) in the Details view and i don't know how to do it.
Here's the class :
public class Consultant
{
public int Id { get; set; }
public int CIN { get; set; }
public string Nom { get; set; }
public string Prenom { get; set; }
public string RefCommercial { get; set; }
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public string DateNaissance { get; set; }
public string Fonction { get; set; }
public string Tel { get; set; }
public string Experience { get; set; }
public string Email { get; set; }
public string CVurl { get; set; }
The attribute CVurl contains the file's name.
Now i want to show the file in the Details view of a consultant.
Any help? Thanks

Related

How to ignore nested models in Swagger (ASP.Net Core 3.1)?

I have a complex model with multiple levels, i am using Swashbuckle.
how can I ignore related models in swagger UI? and show just the first level of the model?
See the below example, I want to ignore all relations like JobTitleVM and ICollection.
public class UserVM
{
public int Id { get; set; }
public Guid Guid { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Token { get; set; }
public string Avatar { get; set; }
public int IsActive { get; set; }
public int JobTitleId { get; set; }
public JobTitleVM JobTitle { get; set; }
public int UserStatusId { get; set; }
public UserStatusVM UserStatus { get; set; }
public virtual ICollection<UserStepsVM> UserSteps { get; set; } = new List<UserStepsVM>();
}

Podio API - Groupings are missing from Views in C#

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

mvc application not adding newly created model to database

I recently added a new model to my MVC application that looks like this
namespace PIC_Program_1._0.Models
{
public class DisposalOrder
{
[Key]
[Display(Name = "DO ID")]
public int ID { get; set; }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
[Display(Name = "Date Created")]
public DateTime DateCreated { get; set; }
[DefaultValue("Pending")]
public DOStatus Status { get; private set; }
public decimal disposed { get; set; }
public string Details { get; set; }
public virtual ICollection<DODetails> DisposalDetails { get; set; }
public virtual Site sites { get; set; }
public virtual Component Components { get; set; }
public virtual Item Items { get; set; }
public virtual Part Parts { get; set; }
public bool deleted { get; set; }
public bool hasBeenReleased { get; set; }
public string Notes { get; private set; }
}
}
But when I run a add-migration and an update database, nothing is changed.
I created the model by right-clicking my Models folder, then typing "Add class" so it should be setup the right way. I'm stumped as to why it's not adding?

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.

Add custom fields for AspNetUser [duplicate]

This question already has answers here:
extend ASP.NET Core Identity user
(2 answers)
Closed 3 years ago.
I am a newbie in ASP.NET Core.
How can I add custom fields to my user model both in code and UI?
Current user management UI is something like this, but I want to add some extra fields, like credit or scores, in model, DB & UI:
And this is my AspNetUser model :
public partial class AspNetUsers
{
public AspNetUsers()
{
AspNetUserClaims = new HashSet<AspNetUserClaims>();
AspNetUserLogins = new HashSet<AspNetUserLogins>();
AspNetUserRoles = new HashSet<AspNetUserRoles>();
AspNetUserTokens = new HashSet<AspNetUserTokens>();
}
public string Id { get; set; }
public string UserName { get; set; }
public string NormalizedUserName { get; set; }
public string Email { get; set; }
public string NormalizedEmail { get; set; }
public bool EmailConfirmed { get; set; }
public string PasswordHash { get; set; }
public string SecurityStamp { get; set; }
public string ConcurrencyStamp { get; set; }
public string PhoneNumber { get; set; }
public bool PhoneNumberConfirmed { get; set; }
public bool TwoFactorEnabled { get; set; }
public DateTimeOffset? LockoutEnd { get; set; }
public bool LockoutEnabled { get; set; }
public int AccessFailedCount { get; set; }
public double Credit { get; set; }
public virtual ICollection<AspNetUserClaims> AspNetUserClaims { get; set; }
public virtual ICollection<AspNetUserLogins> AspNetUserLogins { get; set; }
public virtual ICollection<AspNetUserRoles> AspNetUserRoles { get; set; }
public virtual ICollection<AspNetUserTokens> AspNetUserTokens { get; set; }
}
Custom user data is supported by inheriting from IdentityUser. It's customary to name this type ApplicationUser:
public class ApplicationUser : IdentityUser
{
public string CustomTag { get; set; }
}
The detail steps to customize could be found in Customize the model document .
In ASP.NET Core 2.1 or later, Identity is provided as a Razor Class Library. For more information, see Scaffold Identity in ASP.NET Core projects .
After scaffolding , you can find the profile page in Areas.Identity.Pages.Account.Manage.Index.cshtml , you can add entities in InputModel of Index.cshtml.cs and customize the data in OnGetAsync and OnPostAsync function .