Hi asp777,
For uploading you need to pass UserProfileDetail model class as parameter to UploadProfile Task.
Then set the UserImage in UserProfileDetail model class and add the data to database record.
Then call the SaveChanges method to save in database.
Check with below code.
public async Task<UserResponse> UploadProfile(UserProfileDetail obj_UserProfileDetail)
{
UserResponse obj_Response = new UserResponse();
HttpPostedFile file = HttpContext.Current.Request.Files.Count > 0 ? HttpContext.Current.Request.Files[0] : null;
if (!Request.Content.IsMimeMultipartContent())
{
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
try
{
if (file != null && file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(HttpContext.Current.Server.MapPath("~/User_Images/"), fileName);
file.SaveAs(path);
obj_UserProfileDetail.UserImage = fileName;
obj_UserProfileDetail.FirstName = obj_Parameter.FirstName;
_db.UserProfileDetails.Add(obj_UserProfileDetail);
_db.SaveChanges();
obj_Response.Response = 1;
obj_Response.ErrorMessage = "Error Not Found";
}
}
catch (Exception ex)
{
}
}