public HttpResponseMessage UpdateUser(MemberViewModel objUser) { StatusReturn objReturn; try { if (ApiUserSessionRepository.IsAuthorize(objUser.SessionId)) { ApplicationUser objApplicationUser = UserRepository.MapToApplicationUser(objUser); var retResult = UserRepository.UpdateWifiUser(objApplicationUser); if (retResult == RepositoryResult.Success) { UpdateDb objUpdateDb = new UpdateDb(); objUpdateDb.UpdateUser(objUser.UserName, objUser.Password, objUser.Email, objUser.FirstName, objUser.LastName); } log.Info("User data commited successfully"); objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.UpdateUserSuccess), ReturnCode.UpdateUserSuccess.ToString(), "user details updated "); } else { objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Warning), ReturnCode.Warning.ToString(), "Invalid SessionId"); } } catch (Exception ex) { log.Error(ex.Message); //dbContextTransaction.Rollback(); objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Failure), ReturnCode.Failure.ToString(), "some problem occure"); } return(new HttpResponseMessage() { Content = new StringContent(JsonConvert.SerializeObject(objReturn), Encoding.UTF8, "application/json") }); }
internal static StatusReturn LoadAllFiles() { StatusReturn confStatus = Config.Load(); StatusReturn saveStatus = SavedData.Load(); if (confStatus != StatusReturn.Success && saveStatus != StatusReturn.Success) { Log.Information("Neither a config or savedata file was found", confStatus, saveStatus); return(StatusReturn.NotFound); } else if (confStatus != StatusReturn.Success && saveStatus == StatusReturn.Success) { Log.Information("A config file wasn't found but a savedata file was, generating config file", confStatus, saveStatus); Config.CreateNew(); return(StatusReturn.Success); } else if (saveStatus != StatusReturn.Success && confStatus == StatusReturn.Success) { Log.Information("A savedata file wasn't found but a config file was, generating savedata file", confStatus, saveStatus); SavedData.CreateNew(); return(StatusReturn.Success); } else { Log.Information("All files were found and loaded successfully", confStatus, saveStatus); return(StatusReturn.Success); } }
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") }); }
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") }); }
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 CreateUserExpose(MemberViewModel objUser) { StatusReturn objReturn = null; string strReturn = null; try { CreateMemberValidation objCreateMembershipValidation = new CreateMemberValidation(); ApplicationUser objApplicationUser = UserRepository.MapToApplicationUser(objUser); if (ApiUserSessionRepository.IsAuthorize(objUser.SessionId)) { objCreateMembershipValidation.CheckValidation(objUser); if (!objCreateMembershipValidation.IsNotValidate) { var retResult = UserRepository.CreateWifiUser(objApplicationUser); if (retResult == RepositoryResult.Success) { retResult = UserRepository.CreateUserRole(objApplicationUser); if (retResult == RepositoryResult.Success) { RegisterDB objRegisterDB = new RegisterDB(); objRegisterDB.CreateNewUser(objUser.UserName, objUser.Password, objUser.Email, objUser.FirstName, objUser.LastName); objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Success), ReturnCode.Success.ToString(), Common.Common.Reg_Success); strReturn = JsonConvert.SerializeObject(objReturn); } } } else { strReturn = JsonConvert.SerializeObject(objCreateMembershipValidation.listStatusReturn); } } else { objReturn = new StatusReturn(Convert.ToInt32(ErrorCodeWarning.NonAuthorize), ReturnCode.Warning.ToString(), "Invalid SessionId"); strReturn = JsonConvert.SerializeObject(objReturn); } } catch (Exception ex) { //dbContextTransaction.Rollback(); objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Failure), ReturnCode.Success.ToString(), Common.Common.Reg_Success); strReturn = JsonConvert.SerializeObject(objReturn); } return(new HttpResponseMessage() { Content = new StringContent(strReturn, Encoding.UTF8, "application/json") }); }
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") }); }
public HttpResponseMessage Login(MemberViewModel objMemberViewModel) { string strReturn = null; StatusReturn objReturn = null; try { AuthenticateMemberValidation objCustomMemberShipValidation = new AuthenticateMemberValidation(); objCustomMemberShipValidation.CheckValidation(objMemberViewModel); if (!objCustomMemberShipValidation.IsNotValidate) { if (UserRepository.IsMemberApplicationAdmin(objMemberViewModel.UserName, objMemberViewModel.Password)) { string GenerateSessionId = GenerateUniqueSessionId.GenerateSeesionId(); ApiAccessUserSession objApiUserSession = new ApiAccessUserSession() { UserId = UserRepository.GetUserId(objMemberViewModel.UserName), SessionId = GenerateSessionId }; ApiUserSessionRepository.UpdateCreateUserSession(objApiUserSession); objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.LoginSuccess), ReturnCode.LoginSuccess.ToString(), GenerateSessionId); } else { objReturn = new StatusReturn(Convert.ToInt32(ErrorCodeWarning.IncorrectPassword), ReturnCode.Warning.ToString(), "UserName or Password Not Match"); } strReturn = JsonConvert.SerializeObject(objReturn); } strReturn = JsonConvert.SerializeObject(objCustomMemberShipValidation.listStatusReturn); } catch (Exception ex) { objReturn = new StatusReturn(Convert.ToInt32(ReturnCode.Failure), ReturnCode.Failure.ToString(), "Some Error Occured"); } return(new HttpResponseMessage() { Content = new StringContent(strReturn, 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") }); }