Example #1
0
        public loggedinUser Login(LoginBindingModel obj)
        {
            loggedinUser result = new loggedinUser();


            SqlConnection con = new SqlConnection(connectionString);

            SqlCommand command = new SqlCommand(StoreProcedure.SPLogin, con);

            command.CommandType = CommandType.StoredProcedure;

            command.Parameters.Add(new SqlParameter("@UserName", obj.Email));
            command.Parameters.Add(new SqlParameter("@Password", obj.Password));
            using (con)
            {
                con.Open();
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        result.userID = Convert.ToInt32(reader["userid"]);
                        result.HomeId = Convert.ToString(reader["Homeid"]);
                    }
                }
            }
            if (result != null)
            {
                return(result);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        public IHttpActionResult LoginUser(LoginBindingModel obj)
        {
            //Encrypt password
            string       strAPIKey    = CommonLib.FetchMD5(CommonLib.FetchMD5("Ashwani") + obj.Salt);
            loggedinUser loggedinUser = new loggedinUser();
            BALAccount   accountObj   = new BALAccount();

            loggedinUser = accountObj.LoginUser(obj);

            if (loggedinUser != null && strAPIKey == obj.APIKey)
            {
                return(Content(HttpStatusCode.OK, loggedinUser));
            }
            else
            {
                return(NotFound());
            }
        }
Example #3
0
        public async Task <ActionResult> login(LoginBindingModel obj, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            try
            {
                using (var client = new HttpClient())
                {
                    string strSalt = CommonLib.FetchRandStr(3);
                    //Encrypt password
                    string strAPIKey = CommonLib.FetchMD5(CommonLib.FetchMD5("Ashwani") + strSalt);
                    obj.APIKey         = strAPIKey;
                    obj.Salt           = strSalt;
                    client.BaseAddress = new Uri(spaceX.utilities.configuration.ConfigurationKeys.apiUrl);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    //GET Method
                    HttpResponseMessage response = await client.PostAsJsonAsync("api/account/LoginUser", obj);

                    if (response.IsSuccessStatusCode)
                    {
                        var customerJsonString = await response.Content.ReadAsStringAsync();

                        loggedinUser loggedinUserObj = configuration.JsonDeserialize <loggedinUser>(customerJsonString);

                        Session["loggedinUser"] = loggedinUserObj;
                    }
                    else
                    {
                        ModelState.AddModelError("Email", "Email ID/Password is Incorrect");
                        return(View(obj));
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(View());
        }