public async Task <IActionResult> PutPayment([FromRoute] int id, [FromBody] Payment payment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != payment.PaymentId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
 public ActionResult Edit([Bind(Include = "ID,Name,Accounted,Encrypted,Production")] DBdata dBdata)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dBdata).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dBdata));
 }
示例#3
0
        public async Task <ActionResult> Put(int id, [FromBody] RoomFacility roomFacility)
        {
            if (id != roomFacility.RoomFacilityId)
            {
                return(BadRequest());
            }
            //brand.BrandName = newbrand.BrandName;
            //brand.BrandDescription = newbrand.BrandDescription;
            context.Entry(roomFacility).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(NoContent());
        }
示例#4
0
        public async Task <ActionResult> Put(int id, [FromBody] HotelType hotelType)
        {
            if (id != hotelType.HotelTypeId)
            {
                return(BadRequest());
            }
            //brand.BrandName = newbrand.BrandName;
            //brand.BrandDescription = newbrand.BrandDescription;
            context.Entry(hotelType).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(NoContent());
        }
示例#5
0
        public async Task <ActionResult> Put(int id, [FromBody] Customer ctr)
        {
            if (id != ctr.CustomerId)
            {
                return(BadRequest());
            }
            //brand.BrandName = newbrand.BrandName;
            //brand.BrandDescription = newbrand.BrandDescription;
            _context.Entry(ctr).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
示例#6
0
        public async Task <IActionResult> ChangeState([FromBody] StateDTO body)
        {
            foreach (SafetyDoc item in data.SafetyDocs)
            {
                if (item.Id == body.Id)
                {
                    item.Status            = body.Status;
                    data.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                    break;
                }
            }
            await data.SaveChangesAsync();

            return(Ok());
        }
示例#7
0
        public async Task <IActionResult> Delete(int id)
        {
            foreach (var item in data.Consumers)
            {
                if (item.Id == id)
                {
                    data.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;

                    break;
                }
            }
            await data.SaveChangesAsync();

            return(Ok());
        }
示例#8
0
        public async Task <IActionResult> SetPriority([FromBody] PriorityDTO body)
        {
            foreach (Street item in data.Streets)
            {
                if (item.Name == body.Street)
                {
                    item.Priority          = body.Priority;
                    data.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                    break;
                }
            }

            await data.SaveChangesAsync();

            return(Ok());
        }
        public async Task <IActionResult> Put(int?id, [FromBody] Hotel hotel)
        {
            if (id == null)
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (id != hotel.HotelId)
            {
                return(BadRequest());
            }
            //brand.BrandName = newbrand.BrandName;
            //brand.BrandDescription = newbrand.BrandDescription;
            _context.Entry(hotel).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
示例#10
0
        public ActionResult Edit(Category model)
        {
            try
            {
                int categoryId = (from Category in dBContext.Categories
                                  where model.CategoryName.Equals(Category.CategoryName)
                                  select Category.CategoryId).FirstOrDefault();

                if (categoryId != 0)
                {
                    return(Json("Failure", JsonRequestBehavior.AllowGet));
                }

                dBContext.Entry(model).State = EntityState.Modified;
                dBContext.SaveChanges();
                return(Json("Success", JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(View());
            }
        }