Пример #1
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            SaaSResponse objResponseXML  = new SaaSResponse();
            bool         isAuthenticated = IsAuthenticated(actionContext);

            if (!isAuthenticated)
            {
                var response = new HttpResponseMessage(HttpStatusCode.Unauthorized);
                actionContext.Response = response;
            }
            else
            {
                SaaSLogin    objLoginDTO = new SaaSLogin();
                LoginService objLoginBL = new LoginService();
                string       hMACDetails = FormBufferToString();
                string       user = string.Empty, sharedkey = string.Empty, url = string.Empty;
                string       strHmacString  = string.Empty;
                HMACDetails  objHMACDetails = new HMACDetails();
                objHMACDetails = Newtonsoft.Json.JsonConvert.DeserializeObject <HMACDetails>(hMACDetails);
                if (!string.IsNullOrEmpty(objHMACDetails.user))
                {
                    objLoginDTO.UserName = objHMACDetails.user;
                }
                if (!string.IsNullOrEmpty(objHMACDetails.password))
                {
                    objLoginDTO.Password = objHMACDetails.password;
                }
                bool IsValidUser = objLoginBL.ChkForLoginUserValidated(objLoginDTO);
                if (!IsValidUser)
                {
                    var response = new HttpResponseMessage(HttpStatusCode.Unauthorized);
                    actionContext.Response = response;
                }
            }
        }
Пример #2
0
        public SaaSResponse AuthenticateUser(string uname, string pin)
        {
            bool         IsValidUser    = false;
            SaaSLogin    objLoginDTO    = new SaaSLogin();
            SaaSResponse objResponseXML = new SaaSResponse();

            try
            {
                if (!string.IsNullOrEmpty(uname))
                {
                    objLoginDTO.UserName = uname;
                }
                if (!string.IsNullOrEmpty(pin))
                {
                    objLoginDTO.Password = pin;
                }

                LoginService objLoginBL = new LoginService();
                IsValidUser = objLoginBL.ChkForLoginUserValidated(objLoginDTO);

                //objResponseXML.CrosscareData.Result = objLoginDTO.ToString();
                objResponseXML._saasData = Common.GetXMLFromObject <SaaSLogin>(objLoginDTO);
            }
            catch
            {
                objResponseXML._fault = HttpStatusCode.Unauthorized.ToString();
                // throw new HttpResponseException(HttpStatusCode.Unauthorized);
            }
            return(objResponseXML);
            //return new HttpResponseMessage() { Content = new StringContent(, Encoding.UTF8, "application/xml") };
        }
Пример #3
0
        public SaaSResponse Customer(string uname, string pin)
        {
            SaaSResponse        objResponseXML = new SaaSResponse();
            List <SaaSCustomer> oCustomers     = new List <SaaSCustomer>();
            //oCustomers.GetCustomers();
            //oCustomers.Name = "Krutika";
            //oCustomers.Email = "*****@*****.**";
            //oCustomers.Mobile = "674983";
            //oCustomers.Address = "hskdjfhkj";
            //oCustomers.Notes = "adgfjdagfj";
            CustomerService customer        = new CustomerService();
            var             customerContext = customer.GetCustomers();

            foreach (var item in customerContext)
            {
                oCustomers.Add(new SaaSCustomer()
                {
                    Name = item.Name, Email = item.Email, Mobile = item.Mobile, Address = item.Address, Notes = item.Notes
                });
            }
            objResponseXML._saasData = Common.GetXMLFromObject <List <SaaSCustomer> >(oCustomers);
            return(objResponseXML);
        }