public HttpResponseMessage GetStatusOfUserForSite(LoginWIthNewMacAddressModel model) { AutoLoginStatus returnStatus = new AutoLoginStatus(); try { //Need to check the MacAddress exist for the particular Site with Autologin true if (MacAddressRepository.IsMacAddressExistInParticularSite(model.MacAddress, model.SiteId)) { log.Info("inside Is Any MacAddressExist For Particular Site"); var User = UserRepository.GetUserPerDeviceMacAddress(model.MacAddress, model.SiteId); if (User.AutoLogin == true) { log.Info("Check the AutoLogin of Site or User"); //objReturn.returncode = Convert.ToInt32(ReturnCode.Success); returnStatus.UserName = User.UserName; returnStatus.Password = User.PasswordHash; returnStatus.StatusReturn.ReturnCode = Convert.ToInt32(ReturnCode.Success); } } else { returnStatus.StatusReturn.ReturnCode = Convert.ToInt32(ReturnCode.Warning); } } catch (Exception ex) { log.Error(ex.Message); returnStatus.StatusReturn.ReturnCode = Convert.ToInt32(ReturnCode.Failure); } return(new HttpResponseMessage() { Content = new StringContent(JsonConvert.SerializeObject(returnStatus), 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") }); }