Пример #1
0
        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());
                }
            }
        }
Пример #2
0
 public ActionResult <Leads> Get(int id)
 {
     using (var context = new CRM3Context())
     {
         var lead = context.Leads.Where(l => l.LeadId == id).Single();
         return(lead);
     }
 }
Пример #3
0
 public IActionResult Get()
 {
     using (var context = new CRM3Context())
     {
         var dbcontext = new CRM3Context();
         return(Ok(dbcontext.Leads.AsQueryable()));
     }
 }
Пример #4
0
 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);
     }
 }
Пример #5
0
 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());
         }
     }
 }
Пример #6
0
        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());
                }
            }
        }