Esempio n. 1
0
        public HttpResponseMessage login([FromBody] LoginModel loginm)
        {
            IP = System.Configuration.ConfigurationManager.AppSettings["IP"];
            DataTable dt1    = new DataTable();
            var       result = objAuthorization.checkToken(loginm.token);

            //for token
            dt1 = objloginDL.checkUser(loginm);
            //checking mobile and pin
            if (dt1.Rows.Count > 0)

            {
                //Getting usertype
                usertype = dt1.Rows[0]["userType"].ToString();
                userid   = dt1.Rows[0]["userId"].ToString();

                token         = dt1.Rows[0]["token"].ToString();
                loginm.userId = userid;
                result        = objAuthorization.checkDevicekey(userid, loginm.devicekey);
                if (result == false)
                {
                    loginm.useridFK = Convert.ToInt16(dt1.Rows[0]["id"].ToString());
                    objloginDL.insert_DeicviceDetails(loginm);
                }


                dt2 = objAuthorization.usertype(usertype, dt1);

                dt2.Columns.Add("token", typeof(System.String));

                foreach (DataRow row in dt2.Rows)
                {
                    //need to set value to NewColumn column
                    row["token"]      = token;
                    row["profilePic"] = IP + dt2.Rows[0]["profilePic"].ToString();
                }


                resp = Request.CreateResponse <ResponseModel>(
                    HttpStatusCode.OK,
                    new ResponseModel()
                {
                    message = "login sucessfull", output = dt2, statuscode = Convert.ToInt16(HttpStatusCode.OK)
                }
                    );
                resp.Headers.Add("token", token);

                return(resp);
            }

            else
            {
                resp = Request.CreateResponse <ResponseModel>(HttpStatusCode.OK,
                                                              new ResponseModel()
                {
                    message = "Mobile or Pin Wrong", error = true, statuscode = Convert.ToInt16(HttpStatusCode.OK)
                });
                return(resp);
            }
        }