public async Task <T> GetAsync(int id)
        {
            var entity = await _context.Set <T>().FindAsync(id);

            _context.Entry(entity).State = EntityState.Detached;

            return(entity);
        }
Esempio n. 2
0
        public T Update(T updated)
        {
            if (updated == null)
            {
                return(null);
            }

            context.Set <T>().Attach(updated);
            context.Entry(updated).State = EntityState.Modified;
            context.SaveChanges();

            return(updated);
        }
Esempio n. 3
0
        public bool Edit(T entity)
        {
            _dbContext.Entry(entity).State = EntityState.Modified;
            var changes = _dbContext.SaveChanges();

            return(changes > 0);
        }
        public async Task <IActionResult> PutProfession(int id, Profession profession)
        {
            if (id != profession.profession_id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutPatient([FromRoute] int id, [FromBody] Patient patient)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
        public IActionResult PutPatient(int id, Patient patient)
        {
            Patient p = _context.Patients.Find(id);

            p.Name     = patient.Name;
            p.Email    = patient.Email;
            p.Password = patient.Password;

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

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PatientExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 7
0
        public async Task <IActionResult> PutDoctor(int id, Doctor doctor)
        {
            if (id != doctor.doctor_id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 8
0
        public ActionResult Edit([Bind(Include = "Id,BarCode,Iteration,Location,Comment,SamplingType_Id,SamplingStatus_Id,Appointment_Id")] Sampling sampling, SamplingType samplingType, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                AddNewEntityIfNecessary(sampling, samplingType);

                db.Entry(sampling).State = EntityState.Modified;
                db.SaveChanges(User.Identity.Name);
                if (!string.IsNullOrEmpty(returnUrl))
                {
                    return(Redirect(returnUrl));
                }

                return(RedirectToAction("Index"));
            }

            if (Session["Language"].ToString().ToLower() == "en")
            {
                ViewBag.SamplingStatus_Id = new SelectList(db.SamplingStatus, "Id", "Name", sampling.SamplingStatus_Id);
                ViewBag.SamplingType_Id   = new SelectList(db.SamplingTypes, "Id", "Name", sampling.SamplingType_Id);
            }
            else
            {
                ViewBag.SamplingStatus_Id = new SelectList(db.SamplingStatus, "Id", "NameFr", sampling.SamplingStatus_Id);
                ViewBag.SamplingType_Id   = new SelectList(db.SamplingTypes, "Id", "NameFr", sampling.SamplingType_Id);
            }
            return(View(sampling));
        }
 public ActionResult Edit([Bind(Include = "DoctorTypeID,Label")] DoctorType doctorType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(doctorType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(doctorType));
 }
Esempio n. 10
0
 public ActionResult Edit([Bind(Include = "ID,patientNumber,description,date,startTime")] Request request)
 {
     if (ModelState.IsValid)
     {
         db.Entry(request).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(request));
 }
 public ActionResult Edit([Bind(Include = "Id,Name")] RoleViewModel roleViewModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(roleViewModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(roleViewModel));
 }
 public ActionResult Edit([Bind(Include = "ID,Company,FirstName,LastName,Phone,Address,City,State,Zip,Country")] Supplier supplier)
 {
     if (ModelState.IsValid)
     {
         db.Entry(supplier).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(supplier));
 }
 public ActionResult Edit([Bind(Include = "EmployeeID,LastNameEmployee,FirstNameEmployee,EmailEmployee,AddressEmployee,TelephoneEmployee,BirthDateEmployee,HiringDateEmployee")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
 public ActionResult Edit([Bind(Include = "ID,City,State,Zip,Country,Race,Age,Gender,Origin")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
Esempio n. 15
0
 public ActionResult Edit([Bind(Include = "ItemId,Name,Description")] item item)
 {
     if (ModelState.IsValid)
     {
         db.Entry(item).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(item));
 }
Esempio n. 16
0
 public ActionResult Edit([Bind(Include = "ID,Name,Description,Address,City,State,Zip,Country")] Location location)
 {
     if (ModelState.IsValid)
     {
         db.Entry(location).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(location));
 }
Esempio n. 17
0
 public ActionResult Edit([Bind(Include = "StaffID,LastName,FirstMidName,Profession,Shift,EnrollmentDate")] Staff staff)
 {
     if (ModelState.IsValid)
     {
         db.Entry(staff).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(staff));
 }
 public ActionResult Edit([Bind(Include = "ReasonID,Label,ReasonCost,duration")] Reason reason)
 {
     if (ModelState.IsValid)
     {
         db.Entry(reason).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(reason));
 }
 public ActionResult Edit([Bind(Include = "AppointmentId,Email,DateTime,Note")] Appointment appointment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(appointment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(appointment));
 }
Esempio n. 20
0
 public ActionResult Edit([Bind(Include = "UnitID,Title,Credits")] Unit unit)
 {
     if (ModelState.IsValid)
     {
         db.Entry(unit).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(unit));
 }
Esempio n. 21
0
 public ActionResult Edit([Bind(Include = "StaffID,LastName,FirstMidName,EnrollmentDate")] Patient patient)
 {
     if (ModelState.IsValid)
     {
         db.Entry(patient).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(patient));
 }
Esempio n. 22
0
 public ActionResult Edit([Bind(Include = "RoomID,RoomLabel")] Room room)
 {
     if (ModelState.IsValid)
     {
         db.Entry(room).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(room));
 }
Esempio n. 23
0
 public ActionResult Edit([Bind(Include = "EquipmentID,EquipmentLabel,EquipmentPrice")] Equipment equipment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(equipment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(equipment));
 }
 public ActionResult Edit([Bind(Include = "PatientRecordID,PatientID,PatientHistory")] PatientRecord patientRecord)
 {
     if (ModelState.IsValid)
     {
         db.Entry(patientRecord).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PatientID = new SelectList(db.Patients, "PatientID", "LastNamePatient", patientRecord.PatientID);
     return(View(patientRecord));
 }
Esempio n. 25
0
        public bool Edit(T entity)
        {
            var result = _dbSet.Where(a => a.Id == entity.Id);

            if (result != null)
            {
                _db.Entry(entity).State = EntityState.Modified;
                return(true);
            }
            return(false);
        }
Esempio n. 26
0
 public ActionResult Edit([Bind(Include = "ID,Date,SupplierID,Recieved")] Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SupplierID = new SelectList(db.Suppliers, "ID", "Company", order.SupplierID);
     return(View(order));
 }
Esempio n. 27
0
 public ActionResult Edit([Bind(Include = "Id,Name,Participant_Id")] Family family)
 {
     if (ModelState.IsValid)
     {
         db.Entry(family).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Participant_Id = new SelectList(db.Participants, "Id", "FirstName", family.Participant_Id);
     return(View(family));
 }
 public ActionResult Edit([Bind(Include = "DoctorID,EmployeeID,DoctorTypeID")] Doctor doctor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(doctor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DoctorTypeID = new SelectList(db.DoctorTypes, "DoctorTypeID", "Label", doctor.DoctorTypeID);
     ViewBag.EmployeeID   = new SelectList(db.Employees, "EmployeeID", "LastNameEmployee", doctor.EmployeeID);
     return(View(doctor));
 }
Esempio n. 29
0
 public ActionResult Edit([Bind(Include = "ID,Date,LocationID,CustomerID")] Sale sale)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sale).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerID = new SelectList(db.Customers, "ID", "DisplayAddress", sale.CustomerID);
     ViewBag.LocationID = new SelectList(db.Locations, "ID", "Name", sale.LocationID);
     return(View(sale));
 }
Esempio n. 30
0
 public ActionResult Edit([Bind(Include = "ID,OrderID,ItemID,Quantity,Price")] OrderLine orderLine)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orderLine).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ItemID  = new SelectList(db.Items, "ID", "Name", orderLine.ItemID);
     ViewBag.OrderID = new SelectList(db.Orders, "ID", "ID", orderLine.OrderID);
     return(View(orderLine));
 }