コード例 #1
0
        public IHttpActionResult PutAMPHUR(int id, AMPHUR aMPHUR)
        {
            if (id != aMPHUR.AMPHUR_ID)
            {
                return(BadRequest());
            }

            db.Entry(aMPHUR).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult PutFurniture(int id, Furniture furniture)
        {
            if (id != furniture.id)
            {
                return(BadRequest());
            }

            db.Entry(furniture).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public IHttpActionResult PutEmployee(int id, Employee employee)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}

            if (id != employee.EmployeeID)
            {
                return(BadRequest());
            }

            db.Entry(employee).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #4
0
        public IHttpActionResult PutLivro(int id, LIVRO livro)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}

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

            db.Entry(livro).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #5
0
        public IHttpActionResult PutItem(int id, Item item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #6
0
        public IHttpActionResult PutCustomer(int id, Customer customer)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}

            if (id != customer.CustomerID)
            {
                return(BadRequest());
            }

            db.Entry(customer).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #7
0
 public ActionResult AddOrEdit(Employee emp)
 {
     try
     {
         if (emp.ImageUpload != null)
         {
             string fileName  = Path.GetFileNameWithoutExtension(emp.ImageUpload.FileName);
             string extension = Path.GetExtension(emp.ImageUpload.FileName);
             fileName      = fileName + DateTime.Now.ToString("yymmssfff") + extension;
             emp.ImagePath = "~/AppFiles/Images/" + fileName;
             emp.ImageUpload.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/Images/"), fileName));
         }
         using (DBModel db = new DBModel())
         {
             if (emp.EmployeeID == 0)
             {
                 db.Employees.Add(emp);
                 db.SaveChanges();
             }
             else
             {
                 db.Entry(emp).State = EntityState.Modified;
                 db.SaveChanges();
             }
         }
         return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllEmployee()), message = "Submitted Successfully" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
        public IHttpActionResult PutFlightBooking(int id, FlightBooking flightBooking)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != flightBooking.FlightID)
            {
                return(BadRequest());
            }

            db.Entry(flightBooking).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #9
0
ファイル: KorisniciController.cs プロジェクト: isitum01/PROVO
        public IHttpActionResult PutKorisnici(int id, Korisnici korisnici)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != korisnici.kID)
            {
                return(BadRequest());
            }

            db.Entry(korisnici).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #10
0
        public IHttpActionResult PutReserva(int id, Reserva reserva)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != reserva.ReservaId)
            {
                return(BadRequest());
            }

            db.Entry(reserva).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #11
0
        // PUT api/PhoneBook/5
        public IHttpActionResult Puttblphonebook(int id, tblphonebook tblphonebook)
        {
            if (id != tblphonebook.ContactID)
            {
                return(BadRequest());
            }

            db.Entry(tblphonebook).State = System.Data.Entity.EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #12
0
        public IHttpActionResult PutTypeRisk(int id, TypeRisk typeRisk)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != typeRisk.TypeRiskId)
            {
                return(BadRequest());
            }

            db.Entry(typeRisk).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #13
0
        public async Task <IHttpActionResult> PutEquipment(int id, Equipment equipment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != equipment.eid)
            {
                return(BadRequest());
            }

            db.Entry(equipment).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #14
0
        public IHttpActionResult PutHocSinh(int id, HocSinh hocSinh)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != hocSinh.MaHocSinh)
            {
                return(BadRequest());
            }

            db.Entry(hocSinh).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #15
0
        public IHttpActionResult PutSaleDetails(int id, SaleDetails saleDetails)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != saleDetails.SDetailID)
            {
                return(BadRequest());
            }

            db.Entry(saleDetails).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #16
0
        public IHttpActionResult PutSelf_service(int id, Self_service self_service)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != self_service.transID)
            {
                return(BadRequest());
            }

            db.Entry(self_service).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #17
0
        public IHttpActionResult PutEmployee(int id, Employee employee)
        {
            //   THIS WILL BE HANDLED BE THE ANGULAR 7 PROJECT
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}

            if (id != employee.EmployeeID) // CHECKS IF THE id IN THE EMPLOYEE OBJECT MATCH
            {
                return(BadRequest());      // IF THEY IDS DON'T MATCH IT WILL RETURN BAD REQUEST
            }

            db.Entry(employee).State = EntityState.Modified; // IF IT MATCHES THE EntityState IS CHANGED

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

            return(StatusCode(HttpStatusCode.NoContent)); // THIS EXECUTES IF EVERYTHING GOES WELL
        }
コード例 #18
0
ファイル: NarudzbeController.cs プロジェクト: isitum01/PROVO
        public IHttpActionResult PutNarudzbe(int id, Narudzbe narudzbe)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != narudzbe.nID)
            {
                return(BadRequest());
            }

            db.Entry(narudzbe).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #19
0
        public JsonResult AddOrEdit(Book objBook)
        {
            bool   success = false;
            string message = "";
            int    code    = 400;

            try
            {
                using (DBModel db = new DBModel())
                {
                    if (objBook.IdBook == 0)
                    {
                        db.Book.Add(objBook);
                        db.SaveChanges();
                        message = "Saved Successfully";
                    }
                    else
                    {
                        db.Entry(objBook).State = EntityState.Modified;
                        db.SaveChanges();
                        message = "Updated Successfully";
                    }
                    success = true;
                    code    = 200;
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }

            return(new JsonResult {
                Data = new { success = success, message = message, code = code }
            });
        }
コード例 #20
0
        public IHttpActionResult PutProdukty(int id, Produkty produkty)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}

            if (id != produkty.IdProduktu)
            {
                return(BadRequest());
            }

            db.Entry(produkty).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #21
0
        public async Task <IHttpActionResult> PutMymoMessage(int id, MymoMessage mymoMessage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != mymoMessage.MessageID)
            {
                return(BadRequest());
            }

            db.Entry(mymoMessage).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #22
0
        public IHttpActionResult PutRoomType(int id, RoomType roomType)
        {
            if (id != roomType.roomTypeID)
            {
                return(BadRequest());
            }

            db.Entry(roomType).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #23
0
        public IHttpActionResult PutPedido(long id, Pedido pedido)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pedido.PedidoID)
            {
                return(BadRequest());
            }

            db.Entry(pedido).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #24
0
        public IHttpActionResult PutTraining(int id, Training training)
        {
            if (id != training.TrainingID)
            {
                return(BadRequest());
            }

            db.Entry(training).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #25
0
 public JsonResult AddOrEdit(EmployeeInfo emp)
 {
     try
     {
         //if (emp.ImageUpload != null)
         //{
         //    var fileName = Path.GetFileNameWithoutExtension(emp.ImageUpload.FileName);
         //    var extension = Path.GetExtension(emp.ImageUpload.FileName);
         //    fileName = fileName + DateTime.Now.ToString("yy-MMM-dd ddd") + extension;
         //    emp.ImagePath = "~/AppFiles/ImageFiles/" + fileName;
         //    emp.ImageUpload.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/ImageFiles/"), fileName));
         //}
         using (DBModel db = new DBModel())
         {
             if (emp.EmployeeId == 0)
             {
                 db.EmployeeInfoes.Add(emp);
                 db.SaveChanges();
             }
             else
             {
                 db.Entry(emp).State = EntityState.Modified;
                 db.SaveChanges();
             }
         }
         var json = Json(new { success = true, Message = "Submitted Successfully!" }, JsonRequestBehavior.AllowGet);
         return(json);
     }
     catch (Exception e)
     {
         var json = Json(new { success = false, Message = e.Message }, JsonRequestBehavior.AllowGet);
         return(json);
     }
 }
コード例 #26
0
        public IHttpActionResult PutEmployee(int id, Employee employee)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}
            Employee employeeUpdated;

            if (id != employee.ID)
            {
                return(BadRequest());
            }

            db.Entry(employee).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
                /*to get employee object after being updated*/
                employeeUpdated = db.Employees.Find(id);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(employeeUpdated));
        }
コード例 #27
0
        public IHttpActionResult PutFavoriteOffer(int id, FavoriteOffer favoriteOffer)
        {
            if (id != favoriteOffer.favoriteOfferID)
            {
                return(BadRequest());
            }

            db.Entry(favoriteOffer).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #28
0
        public IHttpActionResult PutContact(int id, Contact contact)
        {
            if (id != contact.Id)
            {
                return(BadRequest());
            }

            db.Entry(contact).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #29
0
        public IHttpActionResult PutOrder(long id, Order order)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != order.OrderId)
            {
                return(BadRequest());
            }

            db.Entry(order).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #30
0
        public IHttpActionResult PutGeoposition(Guid id, Geoposition geoposition)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != geoposition.geoid)
            {
                return(BadRequest());
            }

            db.Entry(geoposition).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }