Esempio n. 1
0
        public IActionResult PutpBroker(int id, [FromBody] pBroker pBroker)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pBroker.pBrokerId)
            {
                return(BadRequest());
            }

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

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

            return(new StatusCodeResult(StatusCodes.Status204NoContent));
        }
        public void Delete(int id)
        {
            PropertyDetails propertyDetails = _context.Set <PropertyDetails>().SingleOrDefault(c => c.Id == id);

            _context.Entry(propertyDetails).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
            _context.SaveChanges();
        }
        public async Task <IActionResult> PutBroker([FromRoute] int id, [FromBody] pBroker item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != item.pBrokerId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
 public ActionResult Edit([Bind(Include = "PropertyID,Name,Description,Price,Category,AvailableDate,EstateAgent,Bedrooms,AddressID,PetsAllowed,IsShared")] Property property)
 {
     if (ModelState.IsValid)
     {
         db.Entry(property).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(property));
 }
 public ActionResult Edit([Bind(Include = "AddressID,House,StreetName,TownName,Postcode,County")] Address address)
 {
     if (ModelState.IsValid)
     {
         db.Entry(address).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(address));
 }
Esempio n. 6
0
 public ActionResult Edit([Bind(Include = "CustomerID,FirstName,Surname,MaritalStatus,ContactNumber,EmailAddress,DateOfBirth,AddressID")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AddressID = new SelectList(db.Addresses, "AddressID", "House", customer.AddressID);
     return(View(customer));
 }
 public ActionResult Edit([Bind(Include = "PropertyImageID,ImageURL,Description,Caption,ImageFormat,Rooms,PropertyID")] PropertyImage propertyImage)
 {
     if (ModelState.IsValid)
     {
         db.Entry(propertyImage).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PropertyID = new SelectList(db.Properties, "PropertyID", "Name", propertyImage.PropertyID);
     return(View(propertyImage));
 }
        public async Task <ActionResult> Edit(int id, [Bind("FirstName", "LastName")] Doctor doctor)
        {
            try
            {
                doctor.DoctorId = id;
                _context.Doctors.Attach(doctor);
                _context.Entry(doctor).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, "Unable to save changes.");
            }
            return(View(doctor));
        }
Esempio n. 9
0
        public async Task <ActionResult> Edit(int id, [Bind("pBrokerageName", "Street", "City", "PostalCode", "Phone", "Website")] pBrokerage _pBrokerage)
        {
            try
            {
                _pBrokerage.pBrokerageId = id;
                _context.pBrokerage.Attach(_pBrokerage);
                _context.Entry(_pBrokerage).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, "Unable to save changes.");
            }
            return(View(_pBrokerage));
        }
Esempio n. 10
0
        public async Task <ActionResult> Edit(int id, [Bind("HospitalName", "Street", "City", "PostalCode", "Phone", "Email", "Website")] Hospital hospital)
        {
            try
            {
                hospital.HospitalId = id;
                _context.Hospitals.Attach(hospital);
                _context.Entry(hospital).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, "Unable to save changes.");
            }
            return(View(hospital));
        }
Esempio n. 11
0
 public virtual void Update(T entity)
 {
     _dbset.Attach(entity);
     _dataContext.Entry(entity).State = EntityState.Modified;
 }