public async Task <ActionResult> DeleteConfirmed(Guid id)
        {
            GuestHouse guestHouse = await _context.GuestHouses.FindAsync(id);

            _context.GuestHouses.Remove(guestHouse);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,City,Street,StreetNr,Region")] GuestHouse guestHouse)
        {
            if (ModelState.IsValid)
            {
                _context.Entry(guestHouse).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(guestHouse));
        }
        // GET: GuestHous/Details/5
        public async Task <ActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GuestHouse guestHouse = await _context.GuestHouses.Include(c => c.Bookeds).Where(c => c.Id == id.Value).SingleOrDefaultAsync();

            if (guestHouse == null)
            {
                return(HttpNotFound());
            }
            return(View(guestHouse));
        }
        // GET: GuestHous/Delete/5
        public async Task <ActionResult> Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GuestHouse guestHouse = await _context.GuestHouses.FindAsync(id);

            if (guestHouse == null)
            {
                return(HttpNotFound());
            }
            return(View(guestHouse));
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,City,Street,StreetNr,Region,Price,Path,CreatedBy")] GuestHouse guestHouse, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    fileName = $"{Guid.NewGuid().ToString()}{Path.GetExtension(fileName)}";
                    ;
                    var path = Path.Combine(Server.MapPath("~/Upload/"), fileName);
                    guestHouse.Path = fileName;
                    file.SaveAs(path);
                }
                guestHouse.Id        = Guid.NewGuid();
                guestHouse.CreatedBy = _context.Users.SingleOrDefault(u => u.UserName == User.Identity.Name);

                _context.GuestHouses.Add(guestHouse);

                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(guestHouse));
        }