public async Task <IActionResult> CreateImageAsync(Photo photo) { if (ModelState.IsValid) { photo.CreatedDate = DateTime.Today; if (photo.PhotoAvatar != null && photo.PhotoAvatar.Length > 0) { photo.ImageMimeType = photo.PhotoAvatar.ContentType; photo.ImageName = Path.GetFileName(photo.PhotoAvatar.FileName); using (var memoryStream = new MemoryStream()) { photo.PhotoAvatar.CopyTo(memoryStream); photo.PhotoFile = memoryStream.ToArray(); } await UploadAsync(photo.PhotoAvatar); _dbContext.Add(photo); _dbContext.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View(photo)); } return(View(photo)); }
public void SaveUserPhoto(Puzzle.Core.Model.Photo photo) { Photo dbPhoto = new Photo() { UserId = photo.UserId, StorageId = "1234", CreateDate = DateTime.Now }; photoContext.Add(dbPhoto); photoContext.SaveChanges(); }
public void InsertPhoto(Photo Photo) { _dbContext.Add(Photo); Save(); }