Example #1
0
        public HttpResponseMessage RefreshToken(HttpRequestMessage request, loginUser lu)
        {
            var jsonObject = new JObject();

            jsonObject.Add("token", GenerateToken(lu.username));
            return(request.CreateResponse(HttpStatusCode.OK, jsonObject));
        }
Example #2
0
        public HttpResponseMessage Login(HttpRequestMessage request, loginUser lu)

        {
            User user = CheckUser(lu.username, lu.password);

            if (user != null)

            {
                // strong typed instance
                var jsonObject = new JObject();
                jsonObject.Add("userid", user.srno);
                jsonObject.Add("username", user.username);
                string imgpath = db.AppKeys.Where(x => x.vKey == "ImagePath").FirstOrDefault().vvalue + user.profilephoto;
                jsonObject.Add("profileimg", imgpath);
                jsonObject.Add("firstname", user.FirstName);
                jsonObject.Add("lastname", user.LastName);
                jsonObject.Add("userRoll", user.userRollstatus);
                jsonObject.Add("businessname", user.BusinessName);
                jsonObject.Add("useremail", user.userEmail);
                jsonObject.Add("useraddress", user.address);
                jsonObject.Add("usermob1", user.mobno1);
                jsonObject.Add("usermob2", user.mobno2);

                if (user.userRollstatus == "S")
                {
                    User   u  = db.Users.Where(d => d.srno == user.DistributorId).FirstOrDefault();
                    string dn = u.FirstName + " " + u.LastName;
                    jsonObject.Add("distributorid", user.DistributorId);
                    jsonObject.Add("distributorName", dn);
                }

                /*
                 * if (user.userRollstatus == "D")
                 * {
                 *  var ts = db.TagStackByDistributor(user.srno.ToString());
                 *  jsonObject.Add("TagStock", JsonConvert.SerializeObject(ts));
                 *  var st = db.GetSalesTeambyDistributorId(user.srno.ToString());
                 *  jsonObject.Add("SalesTeam", JsonConvert.SerializeObject(st));
                 *  var sr = db.salesreportbyDistributorId(user.srno.ToString());
                 *  jsonObject.Add("SalesReport", JsonConvert.SerializeObject(sr));
                 *
                 * }*/
                jsonObject.Add("token", GenerateToken(lu.username));
                return(request.CreateResponse(HttpStatusCode.OK, jsonObject));
            }
            else
            {
                return(new HttpResponseMessage(HttpStatusCode.Unauthorized));
            }
        }