I am currently working on an ASP.Net application that stores student information. I am required to store the following information:
- Student number
- Name
- Email address
- Home address
- Contact no.
- Upload photo of the student
- isActive flag to state whether the student is active or not
This information is being stored in a document database and the photo of the student needs to be uploaded to Azure blob storage while returning the link of the image to the document database
How do I do this?
I currently have a class for the student information which looks like this :
public class Student
{
[Key]
public int StudentId { get; set; }
[Required]
[StringLength(8, MinimumLength = 8)]
[DisplayName("Student Number")]
public string StudentNo { get; set; }
[Required]
[StringLength(50, MinimumLength = 1)]
[DisplayName("First Name")]
public string FirstName { get; set; }
[Required]
[StringLength(50, MinimumLength = 1)]
[DisplayName("Last Name")]
public string LastName { get; set; }
[Required]
[DataType(DataType.EmailAddress)]
[DisplayName("Email Address")]
public string Email { get; set; }
[Required]
[StringLength(100, MinimumLength = 5)]
[DataType(DataType.MultilineText)]
[DisplayName("Home Address")]
public string HomeAddress { get; set; }
[Required]
[DataType(DataType.PhoneNumber)]
[StringLength(10)]
[DisplayName("Mobile No.")]
public string Mobile { get; set; }
public bool IsActive { get; set; }
}
I have a separate view model for the blob as I was still experimenting with blobs:
public class BlobViewModel
{
public string BlobContainerName { get; set; }
public string StorageUri { get; set; }
public string ActualFileName { get; set; }
public string PrimaryUri { get; set; }
public string fileExtension { get; set; }
public string FileNameWithoutExt
{
get
{
return Path.GetFileNameWithoutExtension(ActualFileName);
}
}
public string FileNameExtensionOnly
{
get
{
return System.IO.Path.GetExtension(ActualFileName).Substring(1);
}
}
How do I combine these 2 so that i can upload an image for the student to be stored in a blob while returning the URI to the student class?