public IHttpActionResult Register(RestaurantAccounts model)
        {
            GlobalDesignEntities db = new GlobalDesignEntities();

            db.RestaurantAccounts.Add(new RestaurantAccounts()
            {
                RestaurantName     = model.RestaurantName,
                RestaurantMail     = model.RestaurantMail,
                RestaurantPassword = model.RestaurantPassword,
                ConfirmPassword    = model.ConfirmPassword,
                RestaurantPhone    = model.RestaurantPhone,
                RestaurantAdress   = model.RestaurantAdress,
                RestaurantCity     = model.RestaurantCity,
                RestaurantDistrict = model.RestaurantDistrict
            });
            db.SaveChanges();
            return(Ok());
        }
        public ActionResult Index(RestaurantAccounts user)
        {
            if (ModelState.IsValid)
            {
                HttpClient hc = new HttpClient();
                hc.BaseAddress = new Uri("https://localhost:44382/api/Default");

                var insertrec = hc.PostAsJsonAsync <RestaurantAccounts>("Default", user);
                insertrec.Wait();

                var saverec = insertrec.Result;
                if (saverec.IsSuccessStatusCode)
                {
                    ViewBag.message = "The user " + user.RestaurantName + "is inserted succesfully";
                }
            }
            Response.Cookies.Add(new HttpCookie("RestMail", user.RestaurantMail));
            Response.Cookies.Add(new HttpCookie("RestName", user.RestaurantName));

            return(RedirectToAction("RegisterTableAndWorker", "RegisterTableAndWorker"));
        }
예제 #3
0
        public ActionResult Login(RestaurantAccounts model, string returnUrl)
        {
            GlobalDesignEntities db       = new GlobalDesignEntities();
            RestaurantAccounts   dataItem = db.RestaurantAccounts.FirstOrDefault(x => x.RestaurantMail == model.RestaurantMail && x.RestaurantPassword == model.RestaurantPassword);

            if (dataItem != null)
            {
                FormsAuthentication.SetAuthCookie(dataItem.RestaurantMail, false);
                if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                    !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                {
                    return(Redirect(returnUrl));
                }
                else
                {
                    return(RedirectToAction("MainPage", "Home"));
                }
            }
            else
            {
                ModelState.AddModelError("", "Invalid User or Password");
                return(View());
            }
        }