public HttpResponseMessage UpdateMacAddress(MemberDevicesModel objUserMac)
        {
            StatusReturn objReturn = null;

            try
            {
                if (ApiUserSessionRepository.IsAuthorize(objUserMac.SessionId))
                {
                    if (objUserMac.OperationType == OperationType.Add)
                    {
                        var retResult = MacAddressRepository.RegisterListOfMacAdressToDb(objUserMac);
                        if (retResult == RepositoryResult.Success)
                        {
                            using (CommunicateRTLS objCommunicateRtls = new CommunicateRTLS())
                            {
                                string       strResult        = objCommunicateRtls.RegisterInRealTimeLocationService(objUserMac.MacAddressList.Select(m => m.MacAddress).ToArray()).Result;
                                Notification objServiceReturn = JsonConvert.DeserializeObject <Notification>(strResult);
                                if (objServiceReturn.result.returncode == Convert.ToInt32(RTLSResult.Success))
                                {
                                    objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Success), ReturnCode.Success.ToString(), " ");
                                }
                            }
                        }
                    }
                    else if (objUserMac.OperationType == OperationType.Delete)
                    {
                        var retResult = MacAddressRepository.RemoveListOfMacAddressFromDb(objUserMac);
                        if (retResult == RepositoryResult.Success)
                        {
                            using (CommunicateRTLS objCommunicateRtls = new CommunicateRTLS())
                            {
                                string       strResult        = objCommunicateRtls.DeregisterInRealTimeLocationServices(objUserMac.MacAddressList.Select(m => m.MacAddress).ToArray()).Result;
                                Notification objServiceReturn = JsonConvert.DeserializeObject <Notification>(strResult);
                                if (objServiceReturn.result.returncode == Convert.ToInt32(RTLSResult.Success))
                                {
                                    objReturn = new StatusReturn(Convert.ToInt32(ErrorCodeWarning.SessionIdRequired), ReturnCode.Success.ToString(), " ");
                                }
                            }
                        }
                        else
                        {
                            //Missing or Invalid Operation Type
                        }
                    }
                    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(), "some problem occured");
            }
            return(new HttpResponseMessage()
            {
                Content = new StringContent(JsonConvert.SerializeObject(objReturn), Encoding.UTF8, "application/json")
            });
        }
Beispiel #2
0
        public HttpResponseMessage CreateUserWifi(UserMacAddressDetails objUserMac)
        {
            StatusReturn objReturn = null;

            if (!ModelState.IsValid)
            {
                var response = Request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                return(response);
            }
            try
            {
                RepositoryResult repResult = UserRepository.CreateWifiUser(objUserMac.objUser);
                if (repResult == RepositoryResult.Success)
                {
                    repResult = UserRepository.CreateUserRole(objUserMac.objUser);
                    if (repResult == RepositoryResult.Success)
                    {
                        objUserMac.objMacAddress.UserId = objUserMac.objUser.Id;
                        repResult = MacAddressRepository.CreateNewMacDevice(objUserMac.objMacAddress);
                        if (repResult == RepositoryResult.Success)
                        {
                            objUserMac.objAddress.UserId = objUserMac.objUser.Id;
                            repResult = UserAddressRepository.CreateUserAddress(objUserMac.objAddress);
                            if (repResult == RepositoryResult.Success)
                            {
                                //objRegisterDB.CreateNewUser(objUserMac.objUser.UserName, objUserMac.objUser.PasswordHash, objUserMac.objUser.Email, objUserMac.objUser.FirstName, objUserMac.objUser.LastName);
                                if (UserRepository.IsMemeber(objUserMac.objUser.UserName) && MacAddressRepository.IsMacAddressExistInParticularSite(objUserMac.objMacAddress.MacAddressValue, (int)objUserMac.objUser.SiteId))
                                {
                                    using (CommunicateRTLS objCommunicateRtls = new CommunicateRTLS())
                                    {
                                        string       retResult        = objCommunicateRtls.RegisterInRealTimeLocationService(new[] { objUserMac.objMacAddress.MacAddressValue }).Result;
                                        Notification objServiceReturn = JsonConvert.DeserializeObject <Notification>(retResult);
                                        if (objServiceReturn.result.returncode == Convert.ToInt32(RTLSResult.Success))
                                        {
                                            MacAddressRepository.RegisterMacAddressToRtls(objUserMac.objMacAddress.MacAddressValue);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Success), ReturnCode.Success.ToString(), Common.Common.Reg_Success);
                    //dbContextTransaction.Commit();
                }
            }
            catch (Exception ex)
            {
                //dbContextTransaction.Rollback();
                objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Failure), ReturnCode.Success.ToString(), Common.Common.Reg_Success);
            }
            return(new HttpResponseMessage()
            {
                Content = new StringContent(JsonConvert.SerializeObject(objReturn), Encoding.UTF8, "application/json")
            });
        }
Beispiel #3
0
        public HttpResponseMessage Login(LoginWIthNewMacAddressModel model)
        {
            StatusReturn objReturn = null;

            try
            {
                if (!ModelState.IsValid)
                {
                    var response = Request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                    return(response);
                }
                if (!UserRepository.IsNewUserAsPerSite(model.UserName, model.SiteId))
                {
                    var objWifiUsers = UserRepository.GetUniqueUserPerSite(model.UserName, model.SiteId);
                    if (!MacAddressRepository.IsMacAddressExistInParticularSite(model.MacAddress, model.SiteId))
                    {
                        //log.Info("Check that the particular MacAddress exist or Not for particualr User with Different Site";
                        MacAddress objMac = new MacAddress();
                        objMac.MacAddressValue = model.MacAddress;
                        objMac.UserId          = objWifiUsers.Id;
                        objMac.BrowserName     = model.BrowserName;
                        objMac.UserAgentName   = model.UserAgentName;
                        objMac.OperatingSystem = model.OperatingSystem;
                        objMac.IsMobile        = model.IsMobile;
                        MacAddressRepository.CreateNewMacDevice(objMac);

                        //Save all the Users data in MySql DataBase
                        if (UserRepository.IsMemeber(model.UserName) && MacAddressRepository.IsMacAddressExistInParticularSite(model.UserName, (int)model.SiteId))
                        {
                            using (CommunicateRTLS objCommunicateRtls = new CommunicateRTLS())
                            {
                                string       retResult        = objCommunicateRtls.RegisterInRealTimeLocationService(new[] { model.MacAddress }).Result;
                                Notification objServiceReturn = JsonConvert.DeserializeObject <Notification>(retResult);
                                if (objServiceReturn.result.returncode == Convert.ToInt32(RTLSResult.Success))
                                {
                                    MacAddressRepository.RegisterMacAddressToRtls(model.MacAddress);
                                }
                            }
                        }
                    }
                }
                objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Success), ReturnCode.Success.ToString(), Common.Common.Reg_Success);
            }
            catch (Exception ex)
            {
                objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Failure), ReturnCode.Success.ToString(), Common.Common.Reg_Success);
            }
            return(new HttpResponseMessage()
            {
                Content = new StringContent(JsonConvert.SerializeObject(objReturn), Encoding.UTF8, "application/json")
            });
        }
        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")
            });
        }