public async Task <ListingCreateResponseModel> Create(string title, string description, string imageUrl, decimal price, string userId) { var listing = new Listing() { Id = Guid.NewGuid().ToString(), Title = title, Created = DateTime.UtcNow, Description = description, ImageUrl = imageUrl, Price = price, IsDeleted = false, SellerId = userId }; var messageData = new ListingCreatedMessage { Title = listing.Title, Price = listing.Price }; var id = Guid.NewGuid().ToString(); var message = new Message(messageData, id); this.context.Add(message); this.context.Add(listing); await context.SaveChangesAsync(); await this.publisher.Publish(messageData); await this.MarkMessageAsPublished(message.Id); return(new ListingCreateResponseModel() { Id = listing.Id, Title = listing.Title, Created = listing.Created, Description = listing.Description, ImageUrl = listing.ImageUrl, Price = listing.Price, IsDeleted = listing.IsDeleted, SellerId = listing.SellerId }); }
public async Task <bool> CreateUserSeller(string userNmae, string firstName, string lastName, string email, string phoneNumber, string userId) { var userSeller = new UserSeller { Id = Guid.NewGuid().ToString(), UserName = userNmae, FirstName = firstName, LastName = lastName, Email = email, PhoneNumber = phoneNumber, UserId = userId }; context.Add(userSeller); int result = await context.SaveChangesAsync(); if (result == 0) { return(false); } return(true); }