Ejemplo n.º 1
0
        public HttpResponseMessage GetMacAddress(MemberViewModel model)
        {
            ReturnMacDevices objReturnMac = new ReturnMacDevices();
            StatusReturn     objReturn    = new StatusReturn();

            try
            {
                if (ApiUserSessionRepository.IsAuthorize(model.SessionId))
                {
                    if (UserRepository.IsNewMemberAsPerSite(model.UserId, model.SiteId))
                    {
                        string[] Macs = MacAddressRepository.GetListMacAddress(model.UserId, model.SiteId);
                        foreach (var item in Macs)
                        {
                            MacAddesses objMacAddress = new MacAddesses();
                            objMacAddress.MacAddress = item;
                            objReturnMac.MacAddressList.Add(objMacAddress);
                        }
                        objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.GetMacAddressSuccess), ReturnCode.Success.ToString(), "Successfully return the MacAddresses");
                    }
                    else
                    {
                        objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Warning), ReturnCode.Warning.ToString(), "UserId or SiteId Not Exist");
                    }
                }
                else
                {
                    objReturn = new StatusReturn(Convert.ToInt32(ErrorCodeWarning.NonAuthorize), ErrorCodeWarning.NonAuthorize.ToString(), "Invalid SesssionId" + " " + model.SessionId);
                }
            }
            catch (Exception ex)
            {
                objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Failure), ReturnCode.Failure.ToString(), "Error Occured");
            }
            objReturnMac.objReturn = objReturn;
            return(new HttpResponseMessage()
            {
                Content = new StringContent(JsonConvert.SerializeObject(objReturnMac), Encoding.UTF8, "application/json")
            });
        }
Ejemplo n.º 2
0
        public HttpResponseMessage DeleteWiFiUser(MemberViewModel model)
        {
            StatusReturn objReturn = null;

            try
            {
                if (ApiUserSessionRepository.IsAuthorize(model.SessionId))
                {
                    if (UserRepository.IsMemberRegisterInRTLS(model.UserId, model.SiteId))
                    {
                        using (CommunicateRTLS objCommunicateRtls = new CommunicateRTLS())
                        {
                            var          lstMacAddress    = MacAddressRepository.GetListMacAddress(model.UserId, model.SiteId);
                            string       retResult        = objCommunicateRtls.DeregisterInRealTimeLocationServices(lstMacAddress).Result;
                            Notification objServiceReturn = JsonConvert.DeserializeObject <Notification>(retResult);
                            if (objServiceReturn.result.returncode == Convert.ToInt32(RTLSResult.Success))
                            {
                                UserRepository.RemoveMemberAsUserUniqueId(model.UserId, model.SiteId);
                                objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.DeleteUserSuccess), ReturnCode.DeleteUserSuccess.ToString(), "User Deleted");
                            }
                        }
                    }
                }
                else
                {
                    objReturn = new StatusReturn(Convert.ToInt32(ErrorCodeWarning.NonAuthorize), ReturnCode.Warning.ToString(), "Invalid SessionId");
                }
            }
            catch (Exception ex)
            {
                objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Failure), ReturnCode.Failure.ToString(), "Error Occured");
            }
            return(new HttpResponseMessage()
            {
                Content = new StringContent(JsonConvert.SerializeObject(objReturn), Encoding.UTF8, "application/json")
            });
        }