public async Task <IActionResult> Create([Bind("RestaurantId,RatingValue,Comment")] Rating rating)
        {
            var customer = (from cus in _context.Customer
                            where cus.Email.Equals(User.Identity.Name)
                            select cus).FirstOrDefault();

            var existingRating = (from rate in _context.Rating
                                  where rate.CustomerId == customer.Id && rate.RestaurantId == rating.RestaurantId
                                  select rate

                                  ).ToList();


            if (existingRating.Count > 0)
            {
                ViewData["RestaurantId"] = new SelectList(_context.Set <Restaurant>(), "Id", "RegistredName", rating.RestaurantId);

                ViewData["Error"] = "Invalid: You have already rated this restaurant";
                return(View(rating));
            }

            if (ModelState.IsValid)
            {
                rating.CustomerId = customer.Id;
                _context.Add(rating);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["RestaurantId"] = new SelectList(_context.Set <Restaurant>(), "Id", "RegistredName", rating.RestaurantId);
            return(View(rating));
        }
        public async Task <IActionResult> Create([Bind("Id,Email,Name")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
        public async Task <IActionResult> Create([Bind("Id,RegistredName,Since,Address, Description")] Restaurant restaurant)
        {
            if (ModelState.IsValid)
            {
                _context.Add(restaurant);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(restaurant));
        }