public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            IsUsedReturnUrl = false;
            if (ModelState.IsValid)
            {
                IEnumerable <User> result = DapperManager.Query <User>("MVC5TemplateServer",
                                                                       "SELECT UserID, FamilyName, FirstName FROM [dbo].[User] WHERE UserID = @UserID AND Password = @Password",
                                                                       new { UserID = model.UserID, Password = model.Password });
                if (result.Count() != 0)
                {
                    Session.Add("UserInfo", result.First());
                    FormsAuthentication.RedirectFromLoginPage(model.UserID, false);
                    //FormsAuthentication.SetAuthCookie(model.UserID, false);

                    if (IsUsedReturnUrl &&
                        Url.IsLocalUrl(returnUrl) &&
                        returnUrl.Length > 1 &&
                        returnUrl.StartsWith("/") &&
                        !returnUrl.StartsWith("//") &&
                        !returnUrl.StartsWith("/\\"))
                    {
                        return(this.Redirect(returnUrl));
                    }

                    return(RedirectToAction(string.Empty, "Home"));
                }
                else
                {
                    ModelState.AddModelError(
                        "Login_Error",
                        HttpContext.GetGlobalResourceObject("ResourceError", "Login_LoginError_ErrorMessage").ToString());
                }
            }
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            IEnumerable <User> result = DapperManager.Query <User>(
                "MVC5TemplateServer",
                "SELECT * FROM [dbo].[User]");

            return(View(result));
        }
Ejemplo n.º 3
0
        public IEnumerable <APISuccessResponses> GetGraphResponses(string provider)
        {
            Console.WriteLine($"Getting UnMapped API Responses for {provider}");
            string query = $"select * from APISuccessResponses with (nolock) where Provider ='{provider}' and Mapped=0";

            try
            {
                return(dapper.Query <APISuccessResponses>(query, null, null, true, null, System.Data.CommandType.Text));
            }
            catch (Exception ex)
            {
                ex.Data["MethodAndClass"] = "GetGraphResponses() in GraphRepository";
                throw ex;
            }
        }
Ejemplo n.º 4
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            User user = DapperManager.Query <User>("MVC5TemplateServer",
                                                   "SELECT * FROM [dbo].[User] WHERE UserID = @UserID",
                                                   new { UserID = id }).FirstOrDefault();

            if (user == null)
            {
                return(HttpNotFound());
            }
            return(View(user));
        }
Ejemplo n.º 5
0
 // GET: api/User/5
 public IEnumerable <User> Get(int id)
 {
     return(DapperManager.Query <User>("MVC5TemplateServer", "SELECT * FROM [dbo].[User] WHERE UserID = @UserID AND Password = @Password", new { UserID = id }));
 }
Ejemplo n.º 6
0
 // GET: api/User
 public IEnumerable <User> Get()
 {
     return(DapperManager.Query <User>("MVC5TemplateServer", "SELECT * FROM [dbo].[User]"));
 }