public void AccomodationInfoesCreate()
        {
            AccomodationInfoesController controller = new AccomodationInfoesController();
            AccomodationInfo ai = new AccomodationInfo();
            ai.AccomodationId = 1;
            ai.AccomodationInfoId = 0;
            ai.Address = "TMP9";
            ai.City = "Sarajevo";
            ai.Country = "BiH";
            ai.Email = "*****@*****.**";
            ai.Phone = "387/454+545";
            ai.PostalCode = "71000";
            var result = controller.Create(ai);
            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));

        }
        public void AccomodationInfoesEdit()
        {
            AccomodationInfoesController controller = new AccomodationInfoesController();
            
            AccomodationInfo ai = new AccomodationInfo();
            ai.AccomodationId = 3;
            ai.AccomodationInfoId = 3;
            ai.Address = "TMP9";
            ai.City = "Pariz";
            ai.Country = "BiH";
            ai.Email = "*****@*****.**";
            ai.Phone = "387/454+545";
            ai.PostalCode = "71000";
            var result = controller.Edit(ai);
            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
            
            Assert.IsTrue(controller.ModelState.IsValid);

        }
        public ActionResult NewAccomodation(CreatAccomodationInformation createinformation)
        {
            ViewBag.AccomodationInfoId = new SelectList(db.AccomodationInfoes, "AccomodationInfoId", "Address");
            ViewBag.AccomodationTypeId = new SelectList(db.AccomodationTypes, "AccomodationTypeId", "AccomodationTypeName");
            


            if (ModelState.IsValid)
            {
                AccomodationInfo ai = new AccomodationInfo
                {
                    City = createinformation.City,
                    Email = createinformation.Email,
                    Address = createinformation.Address,
                   
                    Country = createinformation.Country,
                    Phone = createinformation.Phone,
                    PostalCode = createinformation.PostalCode

                };
                db.AccomodationInfoes.Add(ai);
                db.SaveChanges();

                var info = db.AccomodationInfoes.Where(x => x.Email == createinformation.Email && x.Phone == createinformation.Phone).FirstOrDefault();
                Accomodation ac = new Accomodation
                {

                    AccomodationName = createinformation.AccomodationName,
                    AccomodationTypeId = createinformation.AccomodationTypeId,
                    Description = createinformation.Description,
                    NumberOfRooms = createinformation.NumberOfRooms,
                    StarRating = createinformation.StarRating,
                    AccomodationInfoId=info.AccomodationInfoId
                    
                };
                db.Accomodations.Add(ac);
                db.SaveChanges();

                var accomo = db.Accomodations.Where(x=>x.AccomodationName==createinformation.AccomodationName && x.Description==createinformation.Description).FirstOrDefault();
                info.AccomodationId = accomo.AccomodationId;
                db.Entry(info).State = EntityState.Modified;
                db.SaveChanges();



                return RedirectToAction("Create", "Tokens", new { email=info.Email});
               }




            //    db.Accomodations.Add(createinformation);
              //  db.SaveChanges();
          //      return RedirectToAction("Index");

            ViewBag.AccomodationTypeId = new SelectList(db.AccomodationTypes, "AccomodationTypeId", "AccomodationTypeName", createinformation.AccomodationTypeId);
            return View(createinformation);
            }