Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Namn,Antalsovplatser,Smutsigt,BokningId")] Rum rum)
        {
            if (id != rum.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(rum);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RumExists(rum.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(rum));
        }
 public void TestRumRun()
 {
     var rum = new Rum(true);
     var patient = new PatientIdentifier() { InternalId = new Guid(PGuid) };
     var patData = rum.GetPatientData(patient);
     Assert.IsTrue(patData.FindAll(p => p.Patient.InternalId == patient.InternalId).Count == 1, "There are no entries for test patient, why?");
     Assert.IsTrue(patData.FindAll(p => p.Data.FindAll(d => d.OntologicName == "rdf:TestEntry").Count > 0).Count == 1, "PhrPluginEmpty should have been returned DataUnit with a TestEntry.");
     Assert.IsTrue(patData.FindAll(p => p.Data.FindAll(d => d.OntologicName == "rdf:DifferentTestEntry").Count > 0).Count == 0, "DifferentTestEntry should have been filtered out by RUMs' config.");
 }
 public void TestRumInitialization()
 {
     var rum = new Rum(true);
     Assert.IsTrue(rum.getPhrList().Count > 0, "There should be at least one PHR module loaded!");
     Assert.IsTrue(rum.getConfigurators().Count > 0, "There should be at least one Configurator module loaded!");
     Assert.IsTrue(rum.getOutputs().Count > 0, "There should be at least one Output module loaded!");
     Assert.IsTrue(rum.getPhrList().Exists(p=>p.Source.InternalId == new PhrPluginEmpty().Source.InternalId), "Empty test source should be loaded");
     Assert.IsTrue(rum.getConfigurators().Exists(p => p.Source.InternalId == new EmptyConfigurator().Source.InternalId), "Empty configurator should be loaded");
 }
        public void TestRumInitialization()
        {
            var rum = new Rum(true);

            Assert.IsTrue(rum.getPhrList().Count > 0, "There should be at least one PHR module loaded!");
            Assert.IsTrue(rum.getConfigurators().Count > 0, "There should be at least one Configurator module loaded!");
            Assert.IsTrue(rum.getOutputs().Count > 0, "There should be at least one Output module loaded!");
            Assert.IsTrue(rum.getPhrList().Exists(p => p.Source.InternalId == new PhrPluginEmpty().Source.InternalId), "Empty test source should be loaded");
            Assert.IsTrue(rum.getConfigurators().Exists(p => p.Source.InternalId == new EmptyConfigurator().Source.InternalId), "Empty configurator should be loaded");
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,Namn,Antalsovplatser,Smutsigt,BokningId")] Rum rum)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rum);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(rum));
        }
Ejemplo n.º 6
0
    static void Main(string[] args)
    {
        string s   = Console.ReadLine();
        string s1  = s.Split('+')[0];
        string s2  = s.Split('+')[1];
        var    ts1 = Rum.Ters_Cevir(s1);
        var    ts2 = Rum.Ters_Cevir(s2);

        //Console.WriteLine("ts1=" + ts1);
        //Console.WriteLine("ts2=" + ts2);
        Console.WriteLine(Rum.Cevir(ts1 + ts2));
    }
        //[ExpectedException(typeof(HealthServiceAccessDeniedException))]
        public void TestRumRun()
        {
            var rum     = new Rum(true);
            var patient = new PatientIdentifier()
            {
                InternalId = new Guid(PGuid)
            };
            var patData = rum.GetPatientData(patient);

            Assert.IsTrue(patData.FindAll(p => p.Patient.InternalId == patient.InternalId).Count == 1, "There are no entries for test patient, why?");
            Assert.IsTrue(patData.FindAll(p => p.Data.FindAll(d => d.OntologicName == "rdf:TestEntry").Count > 0).Count == 1, "PhrPluginEmpty should have been returned DataUnit with a TestEntry.");
            Assert.IsTrue(patData.FindAll(p => p.Data.FindAll(d => d.OntologicName == "rdf:DifferentTestEntry").Count > 0).Count == 0, "DifferentTestEntry should have been filtered out by RUMs' config.");
        }
        //KONTROLLERAR OM DET FINNS LEDIGA RUM
        public async Task <IActionResult> LookForAvailableRooms(DateTime BookFrom, DateTime BookTo, int NoOfMembers, Rum Rum, string Extrabed)
        {
            //bool overlap = tStartA < tEndB && tStartB < tEndA;
            //bool overlap = a.start < b.end && b.start < a.end;

            //var usergäst = new Gäst();
            var allarum = _context.Rum.Select(x => x).ToList();
            //var allarumid = _context.Rum.Select(x => x.Id).ToList();

            var allaupptagnarum = _context.Bokningar.Where(x => (x.Incheckning <= BookFrom && x.Utcheckning >= BookTo) ||
                                                           (x.Incheckning < BookFrom && (x.Utcheckning > BookFrom && x.Utcheckning < BookTo)) ||
                                                           ((x.Incheckning > BookFrom && x.Incheckning < BookTo) && x.Utcheckning > BookTo) ||
                                                           (x.Incheckning > BookFrom && x.Utcheckning < BookTo))
                                  .Select(x => x.Rum).ToList();
            //var alluptagnaid = allaupptagnarum.Select(x => x.Id).ToList();

            //var allastartinnan = _context.Bokningar.Where(x => x.Incheckning.Day < BookFrom.Day).Select(x => x.Incheckning.Day).ToList();



            var  upptagnaplatser = allaupptagnarum.Select(x => x.Antalsovplatser).Sum();
            var  totalaplatser   = allarum.Select(x => x.Antalsovplatser).Sum();
            bool IsAValidDate    = false;

            //var user = await _userManager.GetUserAsync(User);

            if (totalaplatser - upptagnaplatser >= NoOfMembers) // kollar om det finns plats de datumen
            {
                if (BookFrom >= DateTime.Now.Date && BookTo >= BookFrom)
                {
                    IsAValidDate = true;
                    allarum.RemoveAll(x => allaupptagnarum.Exists(y => y == x));  //Tar bort alla upptagna rum från listan. kvar är rummen som kan bli bokade
                    var aktuelltbokninsrum = allarum.FirstOrDefault(x => x.Antalsovplatser == NoOfMembers);

                    //allarumid.RemoveAll(x => alluptagnaid.Exists(y => y == x));
                    //var aktuelltbokninsrumid = allarumid[0];
                    //var nybokning = new Bokning { Gäst = usergäst, Incheckning = BookFrom, Utcheckning = BookTo, Rum = aktuelltbokninsrum };

                    var nätter       = (BookTo - BookFrom).TotalDays;
                    var totalkostnad = nätter * aktuelltbokninsrum.PrisPerNatt;
                    if (NoOfMembers == 1)
                    {
                        ViewBag.Rumsinfo  = "Vi hittade det perfekta rummet för dig!";
                        ViewBag.Rumsinfo1 = "Kostnaden blir sammanlagt " + totalkostnad + ":- för " + nätter + " nätter.";
                        ViewBag.Rumsinfo2 = "Ska vi slå till?";
                    }
                    else
                    {
                        ViewBag.Rumsinfo  = "Vi hittade det perfekta rummet för erat sällskap!";
                        ViewBag.Rumsinfo1 = "Kostnaden blir sammanlagt " + totalkostnad + ":- för " + nätter + " nätter.";
                        ViewBag.Rumsinfo2 = "Ska vi slå till?";
                    }


                    ViewBag.bookfrom    = BookFrom;
                    ViewBag.bookto      = BookTo;
                    ViewBag.noofmembers = NoOfMembers;
                    ViewBag.Room        = aktuelltbokninsrum.Id;
                    //ViewBag.Room = aktuelltbokninsrumid;
                    ViewBag.antnätter = nätter;
                    ViewBag.kostnad   = totalkostnad;
                    ViewBag.ExtraSäng = Extrabed;

                    ViewBag.IsAValidSearch = IsAValidDate;
                    return(View());
                }
                else
                {
                    IsAValidDate           = false;
                    ViewBag.IsAValidSearch = IsAValidDate;
                    ViewBag.Errormessage1  = "Det verkar som att du har sökt på ogiltiga datum försök igen.";
                    return(View());
                }
            }
            else
            {
                IsAValidDate           = false;
                ViewBag.IsAValidSearch = IsAValidDate;
                ViewBag.Errormessage   = "Det verkar som alla rummen är upptagna. Försök med ett annat datum!";
                return(View());
            }
            //}
            //else {
            //    return Redirect("/Identity/Account/Register"); //dentity/Account/Register
            //}
        }