Example #1
0
        public async Task <IActionResult> PutYearlyReport(long id, YearlyReport yearlyReport)
        {
            if (id != yearlyReport.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #2
0
        public async Task <Report> UpdateGraphAsync(Report report)
        {
            var existingReport = await context.Reports
                                 .Include(x => x.DataSources)
                                 .Include(x => x.DataSets)
                                 .Include(x => x.Variables)
                                 .FirstOrDefaultAsync(x => x.Id == report.Id);

            context.Entry(existingReport).CurrentValues.SetValues(report);

            UpdateDataSources(report, existingReport);
            UpdateDataSets(report, existingReport);
            UpdateVariables(report, existingReport);

            return(report);
        }
        public async Task <IActionResult> PutCarVisit(Guid id, CarVisit carVisit)
        {
            if (id != carVisit.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #4
0
        public ActionResult <Report> PutReportItem(long id, Report report)
        {
            if (id != report.id)
            {
                return(BadRequest());
            }

            else if (ModelState.IsValid)
            {
                report.updatedAt             = DateTime.Now;
                _context.Entry(report).State = EntityState.Modified;
                _context.SaveChanges();

                return(report);
            }
            else
            {
                return(BadRequest());
            }
        }
Example #5
0
        public async Task <ActionResult> Update(int id, Employee emp)
        {
            try
            {
                emp.Id = id;

                _reportContext.Employees.Attach(emp); // one query on DB (find and update)
                var entry = _reportContext.Entry(emp);
                entry.State = EntityState.Modified;   // all properties will be updated according to model's properties of the view. view must have all properties
                                                      // entry.Property(e=>e.BirthDate).IsModified = false; // in case u dont want to modify the field in Db
                                                      // or use update to replace these 3 lines if all properties are modified
                await _reportContext.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch (DbUpdateException e)
            {
                ModelState.AddModelError(string.Empty, "cannot update entity " + e.Message);
            }

            return(View(emp));
        }
 public void Update(T entity)
 {
     dataContext.Entry(entity).State = EntityState.Modified;
 }
Example #7
0
 public async Task UpdateDeliveryReport(VaccineDeliveryReport report)
 {
     _reportContext.Entry(report).State = EntityState.Modified;
     await _reportContext.SaveChangesAsync();
 }
 public async Task UpdateOrderReport(OrderReport report)
 {
     _reportContext.Entry(report).State = EntityState.Modified;
     await _reportContext.SaveChangesAsync();
 }