Ejemplo n.º 1
0
 public virtual void Update(TEntity entityToUpdate)
 {
     try
     {
         dbSet.Attach(entityToUpdate);
         context.Entry(entityToUpdate).State = EntityState.Modified;
         context.SaveChanges();
     }
     catch (DbEntityValidationException dbEx)
     {
         //Add error log here
     }
 }
Ejemplo n.º 2
0
        public void Delete(Hotel h)
        {
            HotelDBEntities ctx = new HotelDBEntities();

            ctx.Hotels.Attach(h);
            ctx.Entry(h).State = System.Data.Entity.EntityState.Deleted;
            ctx.Hotels.Remove(h);
            ctx.SaveChanges();
        }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "HotelNo,HotelName,HotelAddress")] Hotel hotel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hotel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hotel));
 }
 public ActionResult Edit([Bind(Include = "Owner_id,Account_id,FirstName,LastName,Password,Contact_detail")] Hotel_Owner hotel_Owner)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hotel_Owner).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hotel_Owner));
 }
Ejemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "GuestNo,GuestName,GuestAddress")] Guests guests)
 {
     if (ModelState.IsValid)
     {
         db.Entry(guests).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(guests));
 }
Ejemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "Hotel_id,Name,Address,Number_of_room,Hotel_OwnerOwner_id")] Hotel hotel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hotel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Hotel_OwnerOwner_id = new SelectList(db.Hotel_Owner, "Owner_id", "Account_id", hotel.Hotel_OwnerOwner_id);
     return(View(hotel));
 }
Ejemplo n.º 7
0
        public IHttpActionResult PostOrder(Order order)
        {
            try
            {
                //order table.
                if (order.OrderID == 0)
                {
                    db.Orders.Add(order);
                }
                else
                {
                    db.Entry(order).State = EntityState.Modified;
                }

                //order items table
                foreach (var item in order.OrderItems)
                {
                    if (item.OrderItemID == 0)
                    {
                        db.OrderItems.Add(item);
                    }
                    else
                    {
                        db.Entry(item).State = EntityState.Modified;
                    }
                }

                //delete for Order Items.
                foreach (var id in order.DeletedOrderItemIDs.Split(',').Where(x => x != ""))
                {
                    OrderItem x = db.OrderItems.Find(Convert.ToInt64(id));
                    db.OrderItems.Remove(x);
                }

                db.SaveChanges();
                return(Ok());
            } catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "BookingID,HotelNo,GuestNo,DateFrom,DateTo,RoomNo")] Booking booking)
 {
     if (ModelState.IsValid)
     {
         db.Entry(booking).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RoomNo  = new SelectList(db.Room, "RoomNo", "RoomType", booking.RoomNo);
     ViewBag.GuestNo = new SelectList(db.Guests, "GuestNo", "GuestName", booking.GuestNo);
     return(View(booking));
 }
Ejemplo n.º 9
0
        public void Save(Hotel h)
        {
            HotelDBEntities ctx = new HotelDBEntities();

            if (h.HotelId == 0)
            {
                ctx.Hotels.Add(h);
                ctx.SaveChanges();
            }
            else
            {
                ctx.Hotels.Attach(h);
                ctx.Entry(h).State = System.Data.Entity.EntityState.Modified;
                ctx.SaveChanges();
            }
        }
Ejemplo n.º 10
0
        public void Save(Hotel h)
        {
            HotelDBEntities ctx = new HotelDBEntities();

            if (h.HotelID == 0)
            {//neues Hotel einfügen
                ctx.Hotels.Add(h);
                ctx.SaveChanges();
            }
            else
            {//bestehende Hotel aktualisieren
                ctx.Hotels.Attach(h);
                ctx.Entry(h).State = System.Data.Entity.EntityState.Modified;
                ctx.SaveChanges();
            }
        }
Ejemplo n.º 11
0
    public Tipo_Habitacion actualizarTipo(string tipo, string descripcion, double tarifa)
    {
        Tipo_Habitacion habitacion = new Tipo_Habitacion();

        try
        {
            habitacion.descripcion_Tipo_Habitacion = descripcion;
            habitacion.hotel_Tipo_Habitacion       = "Patito";
            habitacion.tarifa_Tipo_Habitacion      = tarifa;
            habitacion.nombre_Tipo_Habitacion      = tipo;
            db.Entry(habitacion).State             = EntityState.Modified;
            db.SaveChanges();
            return(db.Tipo_Habitacion.Find(tipo));
        }
        catch (Exception ex) {
            return(habitacion);
        }
    }
Ejemplo n.º 12
0
    public Facilidad actualizarFacilidad(string id, string descripcion, string nombre)
    {
        Facilidad facilidad = new Facilidad();

        try
        {
            facilidad.hotel_Facilidad       = "Patito";
            facilidad.descripcion_Facilidad = descripcion;
            facilidad.nombre_Facilidad      = nombre;
            facilidad.id_Facilidad          = id;

            db.Entry(facilidad).State = EntityState.Modified;
            db.SaveChanges();
            return(db.Facilidad.Find(id));;
        }
        catch (Exception ex) {
            return(facilidad);
        }
    }
 public ActionResult Index(user user, string userBirth)
 {
     var userSession = (user)Session["user"];
     user.email = userSession.email;
     DateTime newBirthDate = Convert.ToDateTime(userBirth);
     UserPanel modelPanel = new UserPanel();
     using (var db = new HotelDBEntities())
     {
         user currentUser = db.users.FirstOrDefault(u => u.email == user.email);
         if (String.IsNullOrEmpty(user.name) || String.IsNullOrEmpty(user.surname))
         {
             modelPanel.user = currentUser;
             modelPanel.info.type = 0;
             modelPanel.info.text = "You didn't fill name or surname, please fill those fields.";
             return View(modelPanel);
         }
         if (!(String.IsNullOrEmpty(user.password)) && (user.password.Length > 10 || user.password.Length < 6))
         {
             modelPanel.user = currentUser;
             modelPanel.info.type = 0;
             modelPanel.info.text = "Password must be between 6 and 10 characters.";
             return View(modelPanel);
         }
         if (!(String.IsNullOrEmpty(user.password)) && (user.password.Length < 10 || user.password.Length > 6))
         {
             var crypto = new SimpleCrypto.PBKDF2();
             var encrPass = crypto.Compute(user.password);
             currentUser.password = encrPass;
             currentUser.password_salt = crypto.Salt;
         }
         currentUser.name = user.name;
         currentUser.surname = user.surname;
         currentUser.country = user.country;
         currentUser.birth_date = newBirthDate;
         db.users.Attach(currentUser);
         db.Entry(currentUser).Property(p => p.password).IsModified = true;
         db.Entry(currentUser).Property(p => p.password_salt).IsModified = true;
         db.Entry(currentUser).Property(p => p.name).IsModified = true;
         db.Entry(currentUser).Property(p => p.surname).IsModified = true;
         db.Entry(currentUser).Property(p => p.country).IsModified = true;
         db.Entry(currentUser).Property(p => p.birth_date).IsModified = true;
         db.SaveChanges();
         modelPanel.user = currentUser;
         modelPanel.info.type = 1;
         modelPanel.info.text = "Your data has been changed.";
         return View(modelPanel);
     }
 }
 public ActionResult Forgot(string forgotEmail)
 {
     if (Session["user"] != null)
     {
         return RedirectToAction("Index", "Home");
     }
     else
     {
         Message info = new Message();
         if (String.IsNullOrEmpty(forgotEmail))
         {
             info.type = 0;
             info.text = "You didn't fill the e-mail address field.";
         }
         else
         {
             using (var db = new HotelDBEntities())
             {
                 var user = db.users.FirstOrDefault(u => u.email == forgotEmail);
                 if (user == null)
                 {
                     info.text = "User with such e-mail address doesn't exist.";
                 }
                 else
                 {
                     string newPass = "******";
                     var crypto = new SimpleCrypto.PBKDF2();
                     var encrPass = crypto.Compute(newPass);
                     user.password = encrPass;
                     user.password_salt = crypto.Salt;
                     try
                     {
                         db.users.Attach(user);
                         db.Entry(user).Property(p => p.password).IsModified = true;
                         db.Entry(user).Property(p => p.password_salt).IsModified = true;
                         db.SaveChanges();
                         info.type = 1;
                         info.text = "Your password has been changed on: test123.";
                     }
                     catch (Exception e)
                     {
                         info.text = "Unexpected database error.";
                     }
                 }
             }
         }
         return View(info);
     }
 }
Ejemplo n.º 15
0
 // remove later on
 public void UpdateReservation(Reservation reservation)
 {
     entity.Entry(reservation).State = System.Data.Entity.EntityState.Modified;
     entity.SaveChanges();
 }
Ejemplo n.º 16
0
 public void UpdateRoom(Room room)
 {
     entity.Entry(room).State = System.Data.Entity.EntityState.Modified;
     entity.SaveChanges();
 }
Ejemplo n.º 17
0
 public void UpdateStatus(Status St)
 {
     entity.Entry(St).State = System.Data.Entity.EntityState.Modified;
     entity.SaveChanges();
 }
Ejemplo n.º 18
0
 public void UpdateGuest(Guest guest)
 {
     entity.Entry(guest).State = System.Data.Entity.EntityState.Modified;
     entity.SaveChanges();
 }
Ejemplo n.º 19
0
 public void Updatepayment(payment pay)
 {
     entity.Entry(pay).State = System.Data.Entity.EntityState.Modified;
     entity.SaveChanges();
 }