//Create public bool CreateMessage(MessageCreate message) //This needs changed to something that will send the ReceiverHouseId and SenderHouseId in from the Body. { HouseService houseService = new HouseService(); int senderHouseId; using (var ctx = new ApplicationDbContext()) { senderHouseId = houseService.GetHouseIdByOwnerId(_userId); } var entity = new Message() { OwnerId = _userId, SenderHouseId = senderHouseId, ReceiverHouseId = message.ReceiverHouseId, MessageContent = message.MessageContent, DateCreated = DateTimeOffset.Now, }; using (var ctx = new ApplicationDbContext()) { ctx.Messages.Add(entity); return(ctx.SaveChanges() == 1); } }
public PetService(Guid userId) { _userId = userId; HouseService houseService = new HouseService(); _houseId = houseService.GetHouseIdByOwnerId(_userId); }