public async Task <IActionResult> PutLead(long id, Lead lead)
        {
            if (id != lead.id)
            {
                return(BadRequest());
            }

            _context.Entry(lead).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LeadExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> PutQuote(int id, Quote quote)
        {
            if (id != quote.id)
            {
                return(BadRequest());
            }

            _context.Entry(quote).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QuoteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <Battery> > Patch(int id, [FromBody] JsonPatchDocument <Battery> info)
        {
            var battery = await _context.batteries.FindAsync(id);

            info.ApplyTo(battery);
            await _context.SaveChangesAsync();

            return(battery);
        }
예제 #4
0
        public async Task <ActionResult <Elevator> > Patch(int id, [FromBody] JsonPatchDocument <Elevator> info)
        {
            var elevator = await _context.elevators.FindAsync(id);

            info.ApplyTo(elevator);
            await _context.SaveChangesAsync();

            return(elevator);
        }
        public async Task <ActionResult <Column> > Patch(int id, [FromBody] JsonPatchDocument <Column> info)
        {
            var column = await _context.columns.FindAsync(id);

            info.ApplyTo(column);
            await _context.SaveChangesAsync();

            return(column);
        }
예제 #6
0
      public async Task <IActionResult> Create([Bind("VideoID,VideoName,VideoNum,VideoURL")] Video video)
      {
          if (ModelState.IsValid)
          {
              _context.Add(video);
              await _context.SaveChangesAsync();

              return(RedirectToAction(nameof(Index)));
          }
          return(View(video));
      }
예제 #7
0
      public async Task <IActionResult> Create([Bind("PostId,Title,Content,Time")] Post post)
      {
          if (ModelState.IsValid)
          {
              _context.Add(post);
              await _context.SaveChangesAsync();

              return(RedirectToAction(nameof(Index)));
          }
          return(View(post));
      }
예제 #8
0
        public async Task <IActionResult> Create([Bind("ID,Name,Author,Publisher,ISBN,Details,Rank,Price,ImageUrl")] Book book)
        {
            if (ModelState.IsValid)
            {
                _context.Add(book);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
예제 #9
0
        public async Task <IActionResult> Create([Bind("BlogId,BlogUrl,BlogAuthor")] Blog blog)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(blog));
        }
예제 #10
0
        public async Task <ActionResult <Taxon> > PostTaxonItem(Taxon item)
        {
            try
            {
                _infContext.Taxon.Add(item);
                await _infContext.SaveChangesAsync();

                return(CreatedAtAction(nameof(GetTaxonItem), new { id = item.TaxonId }, item));
            }
            catch (System.Exception e)
            {
                var exp = e;
            }
            return(null);
        }
예제 #11
0
        public async Task <ActionResult <Intervention> > Patch(int id, [FromBody] JsonPatchDocument <Intervention> info)
        {
            var intervention = await _context.interventions.FindAsync(id);

            info.ApplyTo(intervention);
            await _context.SaveChangesAsync();

            return(intervention);
        }
예제 #12
0
        public async Task <ActionResult <Intervention> > StartIntervention(long Id)
        {
            var toUpdate = _context.interventions.FirstOrDefault(u => u.id == Id);

            if (toUpdate.startDateIntervention == null && toUpdate.status == "Pending")
            {
                toUpdate.startDateIntervention = DateTime.Now;
                toUpdate.status = "InProgress";
            }
            else
            {
                return(NotFound());
            }


            _context.interventions.Update(toUpdate);
            await _context.SaveChangesAsync();

            return(toUpdate);
        }
예제 #13
0
        public async Task <ActionResult <Intervention> > PostIntervention(Intervention newIntervention)
        {
            newIntervention.start_date_time = DateTime.Now;
            newIntervention.updated_at      = DateTime.Now;
            newIntervention.status          = "InProgress";
            newIntervention.result          = "Incomplete";
            newIntervention.employee_id     = null;

            _context.interventions.Add(newIntervention);
            await _context.SaveChangesAsync();

            return(newIntervention);
        }
예제 #14
0
        public async Task <ActionResult <Customer> > PutCustomer(Customer customer)
        {
            var customerToUpdate = await _context.customers
                                   .Where(c => c.cpy_contact_email == customer.cpy_contact_email)
                                   .FirstOrDefaultAsync();

            if (customerToUpdate == null)
            {
                return(NotFound());
            }

            customerToUpdate.company_name      = customer.company_name;
            customerToUpdate.cpy_contact_name  = customer.cpy_contact_name;
            customerToUpdate.cpy_contact_phone = customer.cpy_contact_phone;
            customerToUpdate.sta_name          = customer.sta_name;
            customerToUpdate.sta_phone         = customer.sta_phone;
            customerToUpdate.sta_mail          = customer.sta_mail;
            customerToUpdate.cpy_description   = customer.cpy_description;

            await _context.SaveChangesAsync();

            return(customerToUpdate);
        }
예제 #15
0
 public async Task Complete()
 {
     await _context.SaveChangesAsync();
 }