コード例 #1
0
        public void Add(TEntity entity)
        {
            var entry = _context.Entry(entity);

            entry.State = EntityState.Added;
            _context.SaveChanges();
            Dispose();
        }
コード例 #2
0
        public async Task <IActionResult> PutBench([FromRoute] int id, [FromBody] Bench bench)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != bench.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #3
0
        public ActionResult Edit([Bind(Include = "ID, patients_pesel, estim_disease, real_disease, dis_descript, appoint_date, specialization, docs_pesel, service_type, service_name, service_price, is_paid, supplies_price")] Appointment appointment)
        {
            AppointmentDBContext context = new AppointmentDBContext();

            if (ModelState.IsValid)
            {
                double time = -1;

                context.Entry(appointment).State = EntityState.Modified;
                context.SaveChanges();

                string query = "UPDATE [dbo].[AppointmentsArch] SET DBUSer = '******' WHERE Idd = '" + appointment.ID + "' AND TypeOfChange = 'UPDATED-INSERTED' AND DateOfChange >= '" + DateTime.Now.AddSeconds(time) + "'";
                db.Database.ExecuteSqlCommand(query);

                query = "UPDATE [dbo].[AppointmentsArch] SET DBUSer = '******' WHERE Idd = '" + appointment.ID + "' AND TypeOfChange = 'UPDATED-DELETED' AND DateOfChange >= '" + DateTime.Now.AddSeconds(time) + "'";
                db.Database.ExecuteSqlCommand(query);

                return(RedirectToAction("Index"));
            }

            return(View(appointment));
        }