コード例 #1
0
        public void InsertTrainees(Models.UserDetail User)

        {
            DBcontext.UserDetails.Add(User);

            DBcontext.SaveChanges();
        }
コード例 #2
0
        public IHttpActionResult Putgame(int id, game game)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != game.game_id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public IHttpActionResult PutBookingTable(int id, BookingTable bookingTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != bookingTable.Ticket_Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #4
0
        public IHttpActionResult PutAspNetUser(string id, AspNetUser aspNetUser)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

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

            if (id != rating.ProductID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #6
0
        private void AddRadnik()
        {
            Random random = new Random();

            Majstor radnik = new Majstor();

            radnik.Radnik               = new Radnik();
            radnik.Radnik.Ime           = Ime;
            radnik.Radnik.Prezime       = Prezime;
            radnik.Radnik.MBR           = MBR;
            radnik.Radnik.Sifra_radnika = random.Next(0, 100);

            string[] speci = Specijalnost.Split(' ');
            radnik.Specijalnost = speci[1];

            radnik.Radnik.Majstor = "";

            entities.Majstors.Add(radnik);
            entities.SaveChanges();

            foreach (Majstor m in entities.Majstors)
            {
                RadnikList.Add(m);
            }

            Ime          = string.Empty;
            Prezime      = string.Empty;
            MBR          = string.Empty;
            Specijalnost = string.Empty;
        }
コード例 #7
0
        public IHttpActionResult PutComment(int id, Comment comment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #8
0
        public ActionResult Create([Bind(Include = "attractionId,address,attractionName")] attraction attraction)
        {
            if (ModelState.IsValid)
            {
                db.attraction.Add(attraction);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(attraction));
        }
コード例 #9
0
        public ActionResult Create([Bind(Include = "Id,Name")] AspNetRoles aspNetRoles)
        {
            if (ModelState.IsValid)
            {
                db.AspNetRoles.Add(aspNetRoles);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aspNetRoles));
        }
コード例 #10
0
        public ActionResult Create([Bind(Include = "Id,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName")] AspNetUsers aspNetUsers)
        {
            if (ModelState.IsValid)
            {
                db.AspNetUsers.Add(aspNetUsers);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aspNetUsers));
        }
コード例 #11
0
        public ActionResult Create([Bind(Include = "EQUIPMENT_ID,EQUIPMENT_NAME,QUANTITY")] EQUIPMENT eQUIPMENT)
        {
            if (ModelState.IsValid)
            {
                db.EQUIPMENTS.Add(eQUIPMENT);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(eQUIPMENT));
        }
コード例 #12
0
        public ActionResult Create([Bind(Include = "ROOM_ID,ROOM_NAME")] ROOM rOOM)
        {
            if (ModelState.IsValid)
            {
                db.ROOMS.Add(rOOM);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rOOM));
        }
コード例 #13
0
        public ActionResult Create([Bind(Include = "id,Title,Discription,ImageUrl,Quantity,Price")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }
コード例 #14
0
        public ActionResult Create([Bind(Include = "ACTIVITY_ID,NAME,PERIOD")] ACTIVITy aCTIVITy)
        {
            if (ModelState.IsValid)
            {
                db.ACTIVITIES.Add(aCTIVITy);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aCTIVITy));
        }
コード例 #15
0
        public ActionResult Create([Bind(Include = "guideId,guideName,guidetype,registerDate")] guide guide)
        {
            if (ModelState.IsValid)
            {
                db.guide.Add(guide);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(guide));
        }
コード例 #16
0
        public ActionResult Create([Bind(Include = "REF_NO,NAME,ADDRESS,DATE_OF_BIRTH")] CUSTOMER cUSTOMER)
        {
            if (ModelState.IsValid)
            {
                db.CUSTOMERS.Add(cUSTOMER);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cUSTOMER));
        }
コード例 #17
0
        public ActionResult Create([Bind(Include = "STAFF_ID,STAFF_NAME,STAFF_DESIGNATION,STAFF_TYPE")] STAFF sTAFF)
        {
            if (ModelState.IsValid)
            {
                db.STAFFS.Add(sTAFF);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sTAFF));
        }
コード例 #18
0
        public ActionResult Create([Bind(Include = "preferenceID,durationDays,attractionName,budget,guideType,generateTime,UID")] userPreference userPreference)
        {
            if (ModelState.IsValid)
            {
                db.userPreference.Add(userPreference);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UID = new SelectList(db.AspNetUsers, "Id", "Email", userPreference.UID);
            return(View(userPreference));
        }
コード例 #19
0
        public ActionResult Create([Bind(Include = "RegionId,Name")] City city)
        {
            if (ModelState.IsValid)
            {
                db.City.Add(city);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RegionId = new SelectList(db.Region, "Id", "Name", city.RegionId);
            return(View(city));
        }
コード例 #20
0
        public ActionResult Create([Bind(Include = "Id,Name,City,Postalcode")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Id = new SelectList(db.Carts, "id", "id", customer.Id);
            return(View(customer));
        }
コード例 #21
0
        public ActionResult Create([Bind(Include = "Id,RootCategoryId,Name")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Category.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RootCategoryId = new SelectList(db.Category, "Id", "Name", category.RootCategoryId);
            return(View(category));
        }
コード例 #22
0
        public ActionResult Create([Bind(Include = "CustomerID,FirstName,LastName,Phone")] CustomerVM customerVM)
        {
            if (ModelState.IsValid)
            {
                var customer = CustomerVM.MapTo(customerVM);
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customerVM));
        }
コード例 #23
0
        public ActionResult Create([Bind(Include = "Name")] Region region)
        {
            if (ModelState.IsValid)
            {
                db.Region.Add(region);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(region));
        }
コード例 #24
0
        public ActionResult Create([Bind(Include = "UId,PName,PPrice")] Package package)
        {
            if (ModelState.IsValid)
            {
                db.Packages.Add(package);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UId = new SelectList(db.AspNetUsers, "Id", "Email", package.UId);
            return(View(package));
        }
コード例 #25
0
        public ActionResult Create([Bind(Include = "ParkingID,ParkingName,Capacity, Zone")] ParkingLotVM parkingLotVM)
        {
            if (ModelState.IsValid)
            {
                var parkingLot = ParkingLotVM.MapTo(parkingLotVM);
                db.ParkingLots.Add(parkingLot);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(parkingLotVM));
        }
コード例 #26
0
        public ActionResult Create([Bind(Include = "SESSION_CODE,START_TIME,ACTIVITY_ID,ROOM_ID,REF_NO")] SESSION sESSION)
        {
            if (ModelState.IsValid)
            {
                db.SESSIONS.Add(sESSION);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ACTIVITY_ID = new SelectList(db.ACTIVITIES, "ACTIVITY_ID", "NAME", sESSION.ACTIVITY_ID);
            ViewBag.REF_NO      = new SelectList(db.CUSTOMERS, "REF_NO", "NAME", sESSION.REF_NO);
            ViewBag.ROOM_ID     = new SelectList(db.ROOMS, "ROOM_ID", "ROOM_NAME", sESSION.ROOM_ID);
            return(View(sESSION));
        }
コード例 #27
0
        public ActionResult Create([Bind(Include = "Id,UserId,CategoryId,CityId,Visits,IsPremium,IsActive,Pub_Time,Exp_Time,Title,Description")] Advertisment advertisment)
        {
            if (ModelState.IsValid)
            {
                db.Advertisment.Add(advertisment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CityId     = new SelectList(db.City, "Id", "Name", advertisment.CityId);
            ViewBag.CategoryId = new SelectList(db.Category, "Id", "Name", advertisment.CategoryId);
            ViewBag.UserId     = new SelectList(db.AspNetUsers, "Id", "Email", advertisment.UserId);
            return(View(advertisment));
        }
コード例 #28
0
        public ActionResult Create([Bind(Include = "tourPlanId,attractionDetails,geneateTime,price,calendar,preferenceID,guideId,attractionId")] tourPlan tourPlan)
        {
            if (ModelState.IsValid)
            {
                db.tourPlan.Add(tourPlan);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.attractionId = new SelectList(db.attraction, "attractionId", "address", tourPlan.attractionId);
            ViewBag.guideId      = new SelectList(db.guide, "guideId", "guideName", tourPlan.guideId);
            ViewBag.preferenceID = new SelectList(db.userPreference, "preferenceID", "attractionName", tourPlan.preferenceID);
            return(View(tourPlan));
        }
コード例 #29
0
        private void AddAlat()
        {
            Alat   alat = new Alat();
            Random rand = new Random();

            alat.Naziv_alata = Naziv;

            alat.Sifra_alata = rand.Next(0, 100);
            entities.Alats.Add(alat);
            entities.SaveChanges();

            alatList.Add(alat);
            Naziv = string.Empty;
        }
コード例 #30
0
        public ActionResult Create([Bind(Include = "ReservationID,CustomerID,ParkingID,StartDate,EndDate")] Reservation reservation)
        {
            if (ModelState.IsValid)
            {
                db.Reservations.Add(reservation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", reservation.CustomerID);
            ViewBag.ParkingID  = new SelectList(db.ParkingLots.GroupBy(x => x.ParkingName).Select(x => x.FirstOrDefault()).ToList(), "ParkingID", "ParkingName");
            var reservationsVM = ReservationVM.MapTo(reservation);

            return(View(reservationsVM));
        }
コード例 #31
0
 public void Perform(Action execute)
 {
     using (var ctx = new Entities2())
     {
         AddToPool(ctx);
         try
         {
             execute();
             ctx.SaveChanges(); //No commit if Exception.
         }
         finally
         {
             RemoveFromPool();
         }
     }
 }