public ActionResult <ScheduledTextModel> Get(int id) { ScheduledText text = repo.GetScheduledTextById(id); if (text is null) { return(NotFound()); } return(mapper.Map <ScheduledTextModel>(text)); }
public ActionResult Delete(int id) { ScheduledText text = repo.GetScheduledTextById(id); if (text is null) { return(NotFound()); } repo.DeleteScheduledText(text.Id); return(Ok()); }
public ActionResult <ScheduledTextModel> Post([FromBody] ScheduledTextModel scheduledText) { ScheduledText text = mapper.Map <ScheduledText>(scheduledText); ScheduledText existing = (from txt in repo.GetScheduledTexts() where txt.PhoneNumber == text.PhoneNumber select txt).FirstOrDefault(); if (existing is null) { repo.CreateScheduledText(text); return(Created($"{HttpContext.Request.GetEncodedUrl()}/{text.Id}", text)); } return(Ok(mapper.Map <ScheduledTextModel>(existing))); }