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") }); }