Example #1
0
        public formular VerificareFormular(int idUser, int idCamin, int idCamera)
        {
            using (RoomsContext context = new RoomsContext())
            {
                var verificare = context.Formular
                                 .Where(formular => (formular.caminID == idCamin) &&
                                        formular.cameraID == idCamera && formular.studentID == idUser)
                                 .Select(formular => formular)

                                 .Cast <formular>();

                int nr_verificari = verificare.Count();

                if (nr_verificari == 0)
                {
                    context.Formular.Add(new formular()
                    {
                        studentID     = idUser,
                        caminID       = idCamin,
                        cameraID      = idCamera,
                        StareFormular = 0
                    });
                    context.SaveChanges();
                    var newId            = context.Formular.Max(x => x.id);
                    var returnedFormular = context.Formular.Where(x => x.id == newId).ToList().FirstOrDefault();
                    return(returnedFormular);
                }
                else
                {
                    throw new Exception("Ai selectat aceasta varianta");
                }
            }
        }
Example #2
0
        public void Create(Room model)
        {
            using (var ctx = new RoomsContext())
            {
                ctx.Rooms.Add(model);

                ctx.SaveChanges();
            }
        }
Example #3
0
        public void AddHumanToRoom(int roomId, int humanId)
        {
            using (var ctx = new RoomsContext())
            {
                var human = ctx.Humans.First(x => x.Id == humanId);

                human.RoomId = roomId;

                ctx.SaveChanges();
            }
        }
Example #4
0
 public void UpdateFormular(formular formular)
 {
     using (RoomsContext context = new RoomsContext())
     {
         formular updateFormular = context.Formular.Where(x => x.id == formular.id).ToList().FirstOrDefault();
         updateFormular.cameraID      = formular.studentID;
         updateFormular.caminID       = formular.caminID;
         updateFormular.cameraID      = formular.cameraID;
         updateFormular.StareFormular = formular.StareFormular;
         context.SaveChanges();
     }
 }
        public RoomsController(RoomsContext context)
        {
            _context = context;

            if (_context.Rooms.Count() == 0)
            {
                _context.Rooms.Add(new Room {
                    Owner = "Kowalski", Capacity = 20
                });
                _context.SaveChanges();
            }
        }
Example #6
0
        public student Valideaza_Date(float medie, string nr_telefon, string facultate, string nume, string prenume)
        {
            using (RoomsContext date_context = new RoomsContext())
            {
                date_context.Student.Add(new student()
                {
                    nume       = nume,
                    prenume    = prenume,
                    medie      = medie,
                    nr_telefon = nr_telefon,
                    facultate  = facultate,
                });
                date_context.SaveChanges();
                var newId = date_context.Student.Max(x => x.id);

                var returnedUser = date_context.Student.Where(x => x.id == newId).ToList().FirstOrDefault();
                return(returnedUser);
            }
        }
Example #7
0
        public utilizator Valideaza_Inregistrare(string username, string password, string firstname, string lastname, string confirmPassword, bool checkInstructor, string email)
        {
            Rol_Utilizator rol = Rol_Utilizator.Membru;

            if (!CheckIfUserExists(username))
            {
                if (checkInstructor)
                {
                    rol = Rol_Utilizator.Administrator;
                }
                if (CheckPassword(password, confirmPassword) && IsValidEmail(email))
                {
                    using (RoomsContext elearningContext = new RoomsContext())
                    {
                        elearningContext.Utilizator.Add(new utilizator()
                        {
                            firstname = firstname,
                            lastname  = lastname,
                            username  = username,
                            password  = password,
                            Role      = rol,
                            email     = email
                        });
                        elearningContext.SaveChanges();
                        var newId = elearningContext.Utilizator.Max(x => x.id);

                        var returnedUser = elearningContext.Utilizator.Where(x => x.id == newId).ToList().FirstOrDefault();
                        return(returnedUser);
                    }
                }
                else
                {
                    throw new System.Exception("Parola sau Email invalid");
                }
            }
            else
            {
                throw new System.Exception("Utilizator deja existent");
            }
        }
Example #8
0
 public void Save()
 {
     _dbContext.SaveChanges();
 }
        public static void Initialize(RoomsContext cntxt)
        {
            if (!cntxt.BedTypes.Any())
            {
                var bt = BedType.Create("TWN", "2 Twin Beds");
                cntxt.BedTypes.Add(bt);
                bt = BedType.Create("DBL", "1 King Bed");
                cntxt.BedTypes.Add(bt);
                bt = BedType.Create("HTW", "Hollywood Twin");
                cntxt.BedTypes.Add(bt);
                bt = BedType.Create("FAM", "1 Double & 1 Twin");
                cntxt.BedTypes.Add(bt);
                cntxt.SaveChanges();
            }

            if (!cntxt.RoomFacilities.Any())
            {
                var f = RoomFacility.Create("TV", "TV");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("COT", "Baby Cot");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("HCH", "Baby High Chair");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("TRO", "Trolley");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("MAT", "Nursing Mat");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("BRC", "Baby Resting Chair");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("BBS", "Dumbo Baby Sitter");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("CCC", "Children's crockery & cutlery");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("BBT", "Baby Bathtub");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("NSM", "Non-slippery bath mat");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("STB", "Stool in the Bathroom");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("PLP", "Plastic Potty");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("SDL", "Safety drawer locks");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("BOI", "Boiler");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("INT", "Internet Connection");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("HAR", "Hair Dryer");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("BAB", "Bathrobes");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("SLP", "Slippers ");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("SAP", "Sun-beds and Parasol ");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("IRO", "Iron & Iron Board");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("BWS", "Bathtub with Shower & WC");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("SHW", "Shower Booth");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("SAF", "Safe Deposit Box");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("CAB", "Cable TV");
                f = RoomFacility.Create("TEL", "Telephone");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("AIR", "Air Condition");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("WOR", "Working Desk");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("PAT", "Patch Cable");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("MIC", "Microwave Oven");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("FRD", "Refrigerator");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("MNB", "Mini Bar");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("SWC", "Shower & WC");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("HCW", "Hot &Cold Water");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("SOF", "Sofa Bed");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("RAI", "Rain-man Shower & WC");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("TOA", "Toaster");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("SUN", "5 Position(Sun Chairs)");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("WEL", "Welcome Package");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("DUX", "Dux Matress");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("CBA", "Children's Bathrobes");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("COS", "Cosmetic Mirror");
                cntxt.RoomFacilities.Add(f);
                f = RoomFacility.Create("BTH", "Bathtub and WC");
                cntxt.RoomFacilities.Add(f);
                cntxt.SaveChanges();
            }

            if (!cntxt.RoomExposures.Any())
            {
                var re = RoomExposure.Create("GAV", "Garden View");
                cntxt.RoomExposures.Add(re);
                re = RoomExposure.Create("POV", "Pool View");
                cntxt.RoomExposures.Add(re);
                re = RoomExposure.Create("SFV", "Sea Facing View");
                cntxt.RoomExposures.Add(re);
                re = RoomExposure.Create("SSV", "Side Sea View");
                cntxt.RoomExposures.Add(re);
                re = RoomExposure.Create("PGV", "Pool and Garden View");
                cntxt.RoomExposures.Add(re);
                re = RoomExposure.Create("BKV", "Back View");
                cntxt.RoomExposures.Add(re);
                cntxt.SaveChanges();
            }

            if (!cntxt.RoomGroups.Any())
            {
                var rg = RoomGroup.Create("STU", "Studio Type");
                cntxt.RoomGroups.Add(rg);
                rg = RoomGroup.Create("HBT", "Studio Happy Baby Type");
                cntxt.RoomGroups.Add(rg);
                rg = RoomGroup.Create("ROY", "Royal Studio Type");
                cntxt.RoomGroups.Add(rg);
                rg = RoomGroup.Create("ROP", "Royal Studio Pool Access Type");
                cntxt.RoomGroups.Add(rg);
                rg = RoomGroup.Create("FAM", "Family Suite Type");
                cntxt.RoomGroups.Add(rg);
                rg = RoomGroup.Create("ROF", "Royal Family Suite Type");
                cntxt.RoomGroups.Add(rg);
                rg = RoomGroup.Create("DLX", "Deluxe Room No Balcony Type");
                cntxt.RoomGroups.Add(rg);
                cntxt.SaveChanges();
            }

            if (!cntxt.RoomTypes.Any())
            {
                var stu = cntxt.RoomGroups.Where(c => c.Code == "STU").FirstOrDefault();
                var hbt = cntxt.RoomGroups.Where(c => c.Code == "HBT").FirstOrDefault();
                var roy = cntxt.RoomGroups.Where(c => c.Code == "ROY").FirstOrDefault();
                var rop = cntxt.RoomGroups.Where(c => c.Code == "ROP").FirstOrDefault();
                var fam = cntxt.RoomGroups.Where(c => c.Code == "FAM").FirstOrDefault();
                var rof = cntxt.RoomGroups.Where(c => c.Code == "ROF").FirstOrDefault();
                var dlx = cntxt.RoomGroups.Where(c => c.Code == "DLX").FirstOrDefault();


                var rt = RoomType.Create("12GAT", "Studio Garden View Terrace", stu, 4);
                cntxt.RoomTypes.Add(rt);
                rt = RoomType.Create("12GAB", "Studio Garden View Balcony", stu, 4);
                cntxt.RoomTypes.Add(rt);
                rt = RoomType.Create("12POT", "Studio Pool View Terrace", stu, 4);
                cntxt.RoomTypes.Add(rt);
                rt = RoomType.Create("12POB", "Studio Pool View Balcony", stu, 4);
                cntxt.RoomTypes.Add(rt);
                rt = RoomType.Create("12HBT", "Studio Happy Baby", hbt, 4);
                cntxt.RoomTypes.Add(rt);
                rt = RoomType.Create("12RPA", "Royal Studio Pool Access", rop, 4);
                cntxt.RoomTypes.Add(rt);
                rt = RoomType.Create("12ROT", "Royal Studio Terrace", roy, 4);
                cntxt.RoomTypes.Add(rt);
                rt = RoomType.Create("12ROB", "Royal Studio Balcony", roy, 4);
                cntxt.RoomTypes.Add(rt);
                rt = RoomType.Create("22POT", "Family Suite Pool View Terrace", fam, 6);
                cntxt.RoomTypes.Add(rt);
                rt = RoomType.Create("22POB", "Family Suite Pool View Balcony", fam, 6);
                cntxt.RoomTypes.Add(rt);
                rt = RoomType.Create("22RPA", "Royal Family Suite Pool Access", fam, 6);
                cntxt.RoomTypes.Add(rt);
                rt = RoomType.Create("22GAB", "Family Suite Garden Balcony", fam, 6);
                cntxt.RoomTypes.Add(rt);
                rt = RoomType.Create("22ROB", "Royal Family Suite Balcony", rof, 6);
                cntxt.RoomTypes.Add(rt);
                rt = RoomType.Create("DLX", "Deluxe Room No Balcony", dlx, 4);
                cntxt.RoomTypes.Add(rt);
                rt = RoomType.Create("22GAT", "Family Suite Garden Terrace", fam, 6);
                cntxt.RoomTypes.Add(rt);
                cntxt.SaveChanges();
            }

            if (!cntxt.RoomLocations.Any())
            {
                var rl = RoomLocation.Create("s", "south");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("n", "north");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B11", "Building 1 1st floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B12", "Building 1 2nd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B13", "Building 1 3rd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B14", "Building 1 4th floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B21", "Building 2 1st floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B22", "Building 2 2nd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B23", "Building 2 3rd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B24", "Building 2 4th floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B31", "Building 3 1st floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B32", "Building 3 2nd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B33", "Building 3 3rd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B41", "Building 4 1st floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B42", "Building 4 2nd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B43", "Building 4 3rd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B44", "Building 4 4th floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B51", "Building 5 1st floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B52", "Building 5 2nd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B53", "Building 5 3rd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B54", "Building 5 4th floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B61", "Building 6 1st floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B62", "Building 6 2nd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B63", "Building 6 3rd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B71", "Building 7 1st floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B72", "Building 7 2nd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B73", "Building 7 3rd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B74", "Building 7 4th floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B81", "Building 8 1st floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B82", "Building 8 2nd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("B83", "Building 8 3rd floor");
                cntxt.RoomLocations.Add(rl);
                rl = RoomLocation.Create("BL", "Lobby Building");
                cntxt.RoomLocations.Add(rl);
                cntxt.SaveChanges();
            }

            if (!cntxt.RoomInfos.Any())
            {
                var rt = cntxt.RoomTypes.Where(r => r.Code == "DLX").FirstOrDefault();
                var bt = cntxt.BedTypes.Where(B => B.Code == "DBL").FirstOrDefault();
                var rl = cntxt.RoomLocations.Where(r => r.Code == "BL").FirstOrDefault();
                var re = cntxt.RoomExposures.Where(e => e.Code == "POV").FirstOrDefault();

                var bkv = cntxt.RoomExposures.Where(e => e.Code == "BKV").FirstOrDefault();
                var gab = cntxt.RoomTypes.Where(r => r.Code == "22GAB").FirstOrDefault();
                var fam = cntxt.BedTypes.Where(B => B.Code == "FAM").FirstOrDefault();
                var b13 = cntxt.RoomLocations.Where(r => r.Code == "B13").FirstOrDefault();
                var gv  = cntxt.RoomExposures.Where(e => e.Code == "GV").FirstOrDefault();

                var rf1 = RoomInfo.Create("1211", rt, bt, rl, re);
                cntxt.RoomInfos.Add(rf1);

                var rf2 = RoomInfo.Create("1212", rt, bt, rl, bkv);
                cntxt.RoomInfos.Add(rf2);

                var rf3 = RoomInfo.Create("1301", gab, fam, b13, gv);
                cntxt.RoomInfos.Add(rf3);

                cntxt.SaveChanges();

                var facilities1 = cntxt.RoomFacilities.OrderBy(x => Guid.NewGuid()).Take(5).ToList();
                var facilities2 = cntxt.RoomFacilities.OrderBy(x => Guid.NewGuid()).Take(5).ToList();
                var facilities3 = cntxt.RoomFacilities.OrderBy(x => Guid.NewGuid()).Take(5).ToList();

                rf1.AddRoomRoomFacility(facilities1);
                rf2.AddRoomRoomFacility(facilities2);
                rf3.AddRoomRoomFacility(facilities3);
                cntxt.SaveChanges();
            }
        }
 public ActionResult <Room> PostRoom(Room roomItem)
 {
     _context.Rooms.Add(roomItem);
     _context.SaveChanges();
     return(NoContent()); //brak uzycia CreateAtAction() z powodu bledu - obiekt zostaje pomyslnie utworzony, ale server zwraca: InvalidOperationException: No route matches the supplied values.
 }