public string Post([FromBody] string value) { ValidateRequest(); UserEventParam getWishParam = JsonConvert.DeserializeObject <UserEventParam>(value); IWishReader wReader = new WishReader(); Wish particularWish = wReader.GetWishForUserAndEvent(getWishParam); return(JsonConvert.SerializeObject(particularWish)); }
private void ValidateDuplicatedWish(Wish wish) { UserEventParam checkExistingParam = new UserEventParam { EventId = (int)wish.EventId, OwnerId = (int)wish.OwnerId }; if (wReader.GetWishForUserAndEvent(checkExistingParam) != null) { throw new WishAlreadyExistsException("A wish for this user and event already exists."); } }
public Wish GetWishForUserAndEvent(UserEventParam param) { string getWishes = $"select * from wishes where OwnerId = {param.OwnerId} and eventid = {param.EventId}"; return(dbr.GetSingleOrDefault <Wish>(getWishes)); }