public Opportunity GetOpportunity(IImageManager imageManager) { string imageUrl = ImageFile == null ? "images\\assets\\Untitled.png" : imageManager.UploadOpportunityImageAsync( ImageFile, ImageFilenameProducer.Create() ).Result; return(new Opportunity { Name = Name, Description = Description, Address = Address, CategoryId = CategoryId, ExternalSignUpUrl = ExternalSignUpUrl, Location = GoogleLocator.GetLocationFromAddress(Address), OpportunityType = OpportunityType, ContactEmail = ContactEmail, ImageUrl = imageUrl }); }
public Opportunity GetOpportunity(ApplicationDbContext context, IImageManager imageManager) { string imageUrl = ImageFile == null ? null : imageManager.UploadOpportunityImageAsync( ImageFile, ImageFilenameProducer.Create() ).Result; var opportunity = context.Opportunities.Find(Id); opportunity.Name = Name; opportunity.Description = Description; opportunity.Address = Address; opportunity.CategoryId = CategoryId; if (imageUrl != null) { opportunity.ImageUrl = imageUrl; } opportunity.ExternalSignUpUrl = ExternalSignUpUrl; opportunity.Location = GoogleLocator.GetLocationFromAddress(Address); opportunity.ContactEmail = ContactEmail; opportunity.UpdatedDateTime = DateTime.Now; return(opportunity); }