public void SavePhoto(int personId, byte[] photoContent, string contentType, string fileName, string imageSize) { var currentPhoto = Context.UploadPhotoes.FirstOrDefault(p => p.PersonId == personId && p.ImageSize == imageSize); if (currentPhoto != null) { Context.DeleteObject(currentPhoto); Context.SaveChanges(); } var newPhoto = new UploadPhoto() { PersonId = personId, Photo = photoContent, ContentType = contentType, FileName = fileName, ImageSize = imageSize }; Context.UploadPhotoes.AddObject(newPhoto); Context.SaveChanges(); }
/// <summary> /// Create a new UploadPhoto object. /// </summary> /// <param name="personId">Initial value of the PersonId property.</param> /// <param name="photo">Initial value of the Photo property.</param> /// <param name="contentType">Initial value of the ContentType property.</param> /// <param name="fileName">Initial value of the FileName property.</param> /// <param name="imageSize">Initial value of the ImageSize property.</param> public static UploadPhoto CreateUploadPhoto(global::System.Int32 personId, global::System.Byte[] photo, global::System.String contentType, global::System.String fileName, global::System.String imageSize) { UploadPhoto uploadPhoto = new UploadPhoto(); uploadPhoto.PersonId = personId; uploadPhoto.Photo = photo; uploadPhoto.ContentType = contentType; uploadPhoto.FileName = fileName; uploadPhoto.ImageSize = imageSize; return uploadPhoto; }
/// <summary> /// Deprecated Method for adding a new object to the UploadPhotoes EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUploadPhotoes(UploadPhoto uploadPhoto) { base.AddObject("UploadPhotoes", uploadPhoto); }