public IActionResult Put(int id, [FromBody] Leads item) { using (var context = new CRM3Context()) { var dbcontext = new CRM3Context(); try { var lead = dbcontext.Leads.Where(l => l.LeadId == id).Single(); lead.Email = item.Email; lead.FirstName = item.FirstName; lead.LastName = item.LastName; lead.Address = item.Address; lead.Ip = item.Ip; lead.Phone = lead.Phone; lead.ZipCode = lead.ZipCode; dbcontext.Leads.Update(lead); dbcontext.SaveChanges(); return(Ok()); } catch (Exception ex) { return(BadRequest()); } } }
public ActionResult <Leads> Get(int id) { using (var context = new CRM3Context()) { var lead = context.Leads.Where(l => l.LeadId == id).Single(); return(lead); } }
public IActionResult Get() { using (var context = new CRM3Context()) { var dbcontext = new CRM3Context(); return(Ok(dbcontext.Leads.AsQueryable())); } }
public ActionResult <IEnumerable <Leads> > Get() { using (var context = new CRM3Context()) { var leads = context.Leads.Where(l => l.OfficeId == 6).OrderByDescending(l => l.DateEntered).Take(100) .ToList(); return(leads); } }
public IActionResult Post(Leads lead) { using (var context = new CRM3Context()) { var dbcontext = new CRM3Context(); try { dbcontext.Leads.Add(lead); dbcontext.SaveChanges(); return(Ok(lead)); } catch (Exception ex) { return(BadRequest()); } } }
public IActionResult Delete(int id) { using (var context = new CRM3Context()) { var dbcontext = new CRM3Context(); try { var lead = dbcontext.Leads.Find(id); if (lead == null) { return(NotFound()); } dbcontext.Leads.Remove(lead); dbcontext.SaveChanges(); return(NoContent()); } catch (Exception ex) { return(BadRequest()); } } }