コード例 #1
0
        public async Task <Amenity> Create(Amenity amenity)
        {
            _context.Entry(amenity).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            await _context.SaveChangesAsync();

            return(amenity);
        }
コード例 #2
0
        public async Task <Room> CreateRoom(Room room)
        {
            _context.Entry(room).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            await _context.SaveChangesAsync();

            return(room);
        }
コード例 #3
0
        public async Task <Hotel> CreateHotel(Hotel hotel)
        {
            _context.Entry(hotel).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            await _context.SaveChangesAsync();

            return(hotel);
        }
コード例 #4
0
        public async Task <HotelRoom> Create(HotelRoom hotelRoom, int hotelId)
        {
            hotelRoom.HotelID = hotelId;
            _context.Entry(hotelRoom).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            await _context.SaveChangesAsync();

            return(hotelRoom);
        }
コード例 #5
0
        public async Task <AmenityDTO> CreateAmenity(AmenityDTO amenity)
        {
            // convert the amenityDTO to an actual entity

            Amenities entity = new Amenities()
            {
                Name = amenity.Name
            };

            _context.Entry(entity).State = EntityState.Added;
            await _context.SaveChangesAsync();

            return(amenity);
        }
コード例 #6
0
        public async Task <IActionResult> PutAmenities(int id, Amenities amenities)
        {
            if (id != amenities.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #7
0
        public virtual async Task <T> UpdateAsync(int id, T entity)
        {
            _dbContext.Entry(entity).State = EntityState.Modified;
            await _dbContext.SaveChangesAsync();

            return(entity);
        }
コード例 #8
0
        public ActionResult Edit(RoomViewModel roomViewModel)
        {
            var room = roomViewModel.Room;

            if (room == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var RoomType = db.RoomTypes.Find(roomViewModel.SelectedTypeId);

            room.Type     = RoomType;
            room.Features = roomViewModel.RoomFeatures
                            .Where(f => f.Checked)
                            .Select(f => db.RoomFeatures.Find(f.Id))
                            .Where(f => f != null)
                            .ToList();
            ModelState.Clear();
            if (TryValidateModel(room))
            {
                db.Entry(room).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(room));
        }
コード例 #9
0
ファイル: EditStaffVM.cs プロジェクト: alicamera/Tim27-DDR2
        public async void spasi(object p)
        {
            using (var db = new HotelDbContext())
            {
                var promijeniti = db.Uposlenici.FirstOrDefault(x => x == ListaRoditelj.Selektovan);
                promijeniti.Username   = Username;
                promijeniti.Password   = Password;
                promijeniti.Ime        = Ime;
                promijeniti.Prezime    = Prezime;
                promijeniti.Email      = Email;
                promijeniti.Telefon    = Telefon;
                promijeniti.Drzava     = Drzava;
                promijeniti.Grad       = Grad;
                promijeniti.Adresa     = Adresa;
                promijeniti.Spol_osobe = spol;
                promijeniti.Plata      = plata;
                promijeniti.Jmbg       = JMBG;


                db.Entry(promijeniti).State = EntityState.Modified;
                db.SaveChanges();
                var dialog = new MessageDialog("Changes saved!");
                await dialog.ShowAsync();
            }
        }
コード例 #10
0
        public async Task <IActionResult> PutRoom(int id, Room room)
        {
            if (id != room.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #11
0
        public async Task <RoomDTO> CreateRoom(RoomDTO dto)
        {
            // convert a roomdto to a room entity.

            Enum.TryParse(dto.Layout, out Layout layout);
            Room room = new Room()
            {
                Name   = dto.Name,
                Layout = layout
            };

            _context.Entry(room).State = EntityState.Added;
            await _context.SaveChangesAsync();

            dto.ID = room.ID;
            return(dto);
        }
コード例 #12
0
 public ActionResult Edit([Bind(Include = "UserId,FirstName,MiddleName,LastName,Mobile,Address,Gender,Email,Password")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
コード例 #13
0
 public ActionResult Edit([Bind(Include = "Id,Value,Name")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
コード例 #14
0
 public ActionResult Edit([Bind(Include = "Id,Title,Description,AdditionalCost")] RoomFeature roomFeature)
 {
     if (ModelState.IsValid)
     {
         db.Entry(roomFeature).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(roomFeature));
 }
コード例 #15
0
 public ActionResult Edit([Bind(Include = "Id,Title,LivingRoomsCount,BasicRate,Description,ImageUrl")] RoomType roomType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(roomType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(roomType));
 }
コード例 #16
0
 public ActionResult Edit([Bind(Include = "HotelId,ImageData,HotelName,HotelAddress,HotelTP,HotelEmail,TotalRooms")] Hotel hotel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hotel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hotel));
 }
コード例 #17
0
 public ActionResult Edit([Bind(Include = "Id,Name,Cpf,Phone,Email,HotelId")] Client client)
 {
     if (ModelState.IsValid)
     {
         db.Entry(client).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.HotelId = new SelectList(db.Hotels, "Id", "Name", client.HotelId);
     return(View(client));
 }
コード例 #18
0
 public ActionResult Edit([Bind(Include = "Id,ClientId,Checkin,Checkout")] Reservation reservation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(reservation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ClientId = new SelectList(db.Clients, "Id", "Name", reservation.ClientId);
     return(View(reservation));
 }
コード例 #19
0
 public ActionResult Edit([Bind(Include = "Id,ClientId")] Billing billing)
 {
     if (ModelState.IsValid)
     {
         db.Entry(billing).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ClientId = new SelectList(db.Clients, "Id", "Name", billing.ClientId);
     return(View(billing));
 }
コード例 #20
0
ファイル: RoomsController.cs プロジェクト: ernaniwings/HOTEL
 public ActionResult Edit([Bind(Include = "Id,Type,HotelId")] Room room)
 {
     if (ModelState.IsValid)
     {
         db.Entry(room).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.HotelId = new SelectList(db.Hotels, "Id", "Name", room.HotelId);
     return(View(room));
 }
コード例 #21
0
 public ActionResult Edit([Bind(Include = "Id,Name,Description,ApplicationUserId")] Hotel hotel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hotel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ApplicationUserId = new SelectList(db.Users, "Id", "Name", hotel.ApplicationUserId);
     return(View(hotel));
 }
コード例 #22
0
        public async Task <PaymentDomain> UpdateAsync(PaymentUpdateModel model)
        {
            var existing = await Get(model);

            Context.Entry(existing).State = EntityState.Modified;
            var result = Mapper.Map(model, existing);

            Context.Update(result);
            await Context.SaveChangesAsync();

            return(Mapper.Map <PaymentDomain>(result));
        }
コード例 #23
0
ファイル: DiscountRepository.cs プロジェクト: olwg199/Hotel
        public void Update(Discount item)
        {
            var discount = _context.Discounts.Find(item.Id);

            if (discount == null)
            {
                throw new ArgumentException("Discount with current Id not found");
            }

            _context.Entry(item).State = EntityState.Modified;
            _context.SaveChanges();
        }
コード例 #24
0
        public async Task <bool> UpdateAsync(Hotel hotel)
        {
            _context.Entry(hotel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!await HotelExistsAsync(hotel.Id))
                {
                    return(false);
                }
                else
                {
                    throw;
                }
            }
            return(true);
        }
コード例 #25
0
        public async void PromjenaOstalo(object p)
        {
            bool trebaLogOut = false;

            using (var db = new HotelDbContext())
            {
                var korisnik = db.Korisnici.First();
                if (AdminParent != null)
                {
                    korisnik = db.Korisnici.FirstOrDefault(kor => kor.Username == AdminParent.Parent.Username && kor.Password == AdminParent.Parent.Password);
                }
                else if (RecepcionarParent != null)
                {
                    korisnik = db.Korisnici.FirstOrDefault(kor => kor.Username == RecepcionarParent.Parent.Username && kor.Password == RecepcionarParent.Parent.Password);
                }
                else if (GostParent != null)
                {
                    korisnik = db.Korisnici.FirstOrDefault(kor => kor.Username == GostParent.Parent.Username && kor.Password == GostParent.Parent.Password);
                }
                else if (SobaricaParent != null)
                {
                    korisnik = db.Korisnici.FirstOrDefault(kor => kor.Username == SobaricaParent.Parent.Username && kor.Password == SobaricaParent.Parent.Password);
                }

                korisnik.Ime        = Ime;
                korisnik.Prezime    = Prezime;
                korisnik.Adresa     = Adresa;
                korisnik.Grad       = Grad;
                korisnik.Spol_osobe = Spol;
                if (korisnik.Username != Username)
                {
                    korisnik.Username = Username;
                    trebaLogOut       = true;
                }
                korisnik.Telefon      = Telefon;
                korisnik.Email        = Email;
                korisnik.Dat_rodjenja = DatumRodjenja;
                korisnik.Drzava       = Drzava;

                db.Entry(korisnik).State = EntityState.Modified;
                db.SaveChanges();
                var dialog = new MessageDialog("Changes saved!");
                await dialog.ShowAsync();

                //cim promjeni username odlogujemo ga
                if (trebaLogOut)
                {
                    trebaLogOut = false;
                    NavigationService.Navigate(typeof(Prijava));
                }
            }
        }
コード例 #26
0
        public async void PromjenaPass(object p)
        {
            using (var db = new HotelDbContext())
            {
                var korisnik = db.Korisnici.First();
                if (AdminParent != null)
                {
                    korisnik = db.Korisnici.FirstOrDefault(kor => kor.Username == AdminParent.Parent.Username && kor.Password == AdminParent.Parent.Password);
                }
                else if (RecepcionarParent != null)
                {
                    korisnik = db.Korisnici.FirstOrDefault(kor => kor.Username == RecepcionarParent.Parent.Username && kor.Password == RecepcionarParent.Parent.Password);
                }
                else if (GostParent != null)
                {
                    korisnik = db.Korisnici.FirstOrDefault(kor => kor.Username == GostParent.Parent.Username && kor.Password == GostParent.Parent.Password);
                }
                else if (SobaricaParent != null)
                {
                    korisnik = db.Korisnici.FirstOrDefault(kor => kor.Username == SobaricaParent.Parent.Username && kor.Password == SobaricaParent.Parent.Password);
                }

                if (korisnik.Password != CurrentPassword)
                {
                    var dialog = new MessageDialog("Incorrect password!\nPlease, re-enter your password.");
                    dialog.Title = "Error";
                    await dialog.ShowAsync();
                }
                else
                {
                    if (NewPassword != ConfirmPassword)
                    {
                        var dialog = new MessageDialog("Passwords don't match!\nPlease, re-enter your new password.");
                        dialog.Title = "Error";
                        await dialog.ShowAsync();
                    }
                    else
                    {
                        korisnik.Password = NewPassword;

                        db.Entry(korisnik).State = EntityState.Modified;
                        db.SaveChanges();
                        var dialog = new MessageDialog("Your password has been changed successfully!");
                        await dialog.ShowAsync();

                        //cim promjeni password odlogujemo ga
                        NavigationService.Navigate(typeof(Prijava));
                    }
                }
            }
        }
コード例 #27
0
        public ActionResult Edit(int id, BookingState state)
        {
            Booking booking = db.Bookings.Find(id);

            if (booking == null)
            {
                return(RedirectToAction("Index"));
            }
            booking.State           = state;
            booking.Employee        = db.Users.Find(User.Identity.GetUserId());
            db.Entry(booking).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #28
0
 /// <summary>
 ///     Updating a confirmation in the database
 /// </summary>
 /// <param name="confirmation">Confirmation entity</param>
 public bool Update(Confirmation confirmation)
 {
     try
     {
         var entity = new Confirmation
         {
             Id = confirmation.CustomerRequestId,
             CustomerRequestId = confirmation.CustomerRequestId,
             RoomId            = confirmation.RoomId,
             IsDeleted         = confirmation.IsDeleted
         };
         _hotelDbContext.Entry(entity).State = EntityState.Modified;
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #29
0
        public async Task <bool> UpdateHotelRooms(int hotelId, HotelRoom hotelRoom)
        {
            var hotelRooms = await _context.HotelRoom
                             .FirstOrDefaultAsync(hr => hr.HotelId == hotelId && hr.Number == hotelRoom.Number);

            if (hotelRoom == null)
            {
                return(false);
            }

            hotelRoom.Rate   = hotelRoom.Rate;
            hotelRoom.RoomID = hotelRoom.RoomID;

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

            await _context.SaveChangesAsync();

            return(true);
        }
コード例 #30
0
 public async Task <bool> UpdateAmenity(Amenity amenity)
 {
     _context.Entry(amenity).State = EntityState.Modified;
     try
     {
         await _context.SaveChangesAsync();
     }
     catch (DbUpdateConcurrencyException)
     {
         if (!await AmenityExistsAsync((int)amenity.Id))
         {
             return(false);
         }
         else
         {
             throw;
         }
     }
     return(true);
 }