public string Getresult(string appkey, string tokenid) { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { string strJson = string.Empty; Guid appkeyvalue = Guid.Parse(appkey); var checktoken = (from atc in DB.AccessTokenCaches where atc.Token == tokenid select atc.Token).ToList(); if (checktoken != null && checktoken.Count() != 0) { var appkeyvalu = (from am in DB.AccountManagemets where am.AppKey == appkeyvalue select am.AppKey).ToList(); if (appkeyvalu != null && appkeyvalu.Count() != 0) { return("true"); } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; // response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(strJson); } } else { strJson = "{\"Result\":\"Invalide Token\"}"; // response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(strJson); } } //return "false"; }
public HttpResponseMessage AddAppKey(AccessAppKey objAccessAppKeys, string Token) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { AccessAppKey objAccessAppKey = new AccessAppKey(); objAccessAppKey.AccountId = objAccessAppKeys.AccountId; objAccessAppKey.AppKey = Guid.NewGuid(); objAccessAppKey.description = objAccessAppKeys.description; DB.AccessAppKeys.InsertOnSubmit(objAccessAppKey); DB.SubmitChanges(); } strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage AddRolesData(RoleMaster objRole, string Token) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { RoleMaster objRoleMaster = new RoleMaster(); objRoleMaster.RoleName = objRole.RoleName; objRoleMaster.RoleDesc = objRole.RoleDesc; objRoleMaster.CreatedDateTime = DateTime.Now; objRoleMaster.CreatedBy = String.Format("{0}{1}", Token.Substring(0, 15), DateTime.Now.ToString()); DB.RoleMasters.InsertOnSubmit(objRoleMaster); DB.SubmitChanges(); strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage AddAccountManagemetData(AccountManagemet objSt, string Token) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { AccountManagemet objAccountManagemet = new AccountManagemet(); objAccountManagemet.AccountID = objSt.AccountID; objAccountManagemet.AccountName = objSt.AccountName; objAccountManagemet.UpdatedBy = String.Format("{0}{1}", Token.Substring(0, 15), DateTime.Now.ToString()); objAccountManagemet.UpdatedDateTime = DateTime.Now; objAccountManagemet.AccountDesc = objSt.AccountDesc; DB.AccountManagemets.InsertOnSubmit(objAccountManagemet); DB.SubmitChanges(); strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage createIpDetails(CCTV_Detail objSt, string Token, string Appkey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(Appkey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { if (objSt != null) { var cctvmanagment = DB.CCTV_Details.Where(x => x.AccountID == objSt.AccountID).FirstOrDefault(); if (cctvmanagment == null) { CCTV_Detail objCCTVManagemet = new CCTV_Detail(); objCCTVManagemet.AccountID = objSt.AccountID; objCCTVManagemet.IP = objSt.IP; objCCTVManagemet.Port = objSt.Port; objCCTVManagemet.Username = objSt.Username; objCCTVManagemet.Password = objSt.Password; DB.CCTV_Details.InsertOnSubmit(objCCTVManagemet); DB.SubmitChanges(); strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"AccountID is Already Use\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } else { strJson = "{\"Result\":\"No Input request was passed in the body\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } else { strJson = "{\"Result\":\"Invalid credentials\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage PostLocation(string Token, Int32 DeviceId, string Lat, string Long, DateTime Time) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var PostLocationInfo = DB.DeviceLocationHistories.FirstOrDefault(x => x.DeviceId == DeviceId); if (PostLocationInfo != null) { PostLocationInfo.Lat = Lat; PostLocationInfo.Long = Long; PostLocationInfo.DateTime = Time; DB.SubmitChanges(); strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage GetUserInformation(string AccountId, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var UserInformation = (from objUserManagements in DB.UserManagements join objUserContactDets in DB.UserContactDets on objUserManagements.UserId equals objUserContactDets.UserId join objvehicalmaster in DB.VehicleMasters on objUserManagements.AccountID equals objvehicalmaster.AccountId join objUserDeviceMapDets in DB.VehicleDeviceMapDets on objvehicalmaster.VehicleID equals objUserDeviceMapDets.vehicleId into g //join objUserLoginDets in DB.UserLoginDets on objUserManagements.UserName equals objUserLoginDets.UserId where objUserManagements.AccountID == AccountId select new { UserId = objUserManagements.UserId, UserName = objUserManagements.UserName, RoleId = objUserManagements.RoleId, AccountID = objUserManagements.AccountID, PhoneNumber = objUserContactDets.PhoneNumber, PostalAddress = objUserContactDets.PostalAddress, EmailAddress = objUserContactDets.EmailAddress, PreferredAlert = objUserContactDets.PreferredAlert, DeviceId = g.Select(x => x.DeviceId).FirstOrDefault(), // LastLoginDateTime= objUserLoginDets.LastLoginDateTime, // UpdatedDateTime=objUserLoginDets.UpdatedDateTime }).ToList(); if (UserInformation != null) { response.Content = new StringContent(JsonConvert.SerializeObject(UserInformation), Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage AddRouteData(Route objRouteDetail, string Token) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { foreach (var route in objRouteDetail.RouteDetail) { RouteDetail objroute = new RouteDetail(); objroute.RouteId = objRouteDetail.routeId; objroute.SeqNo = route.SeqNo; objroute.Lat = route.Lat; objroute.Long = route.Long; DB.RouteDetails.InsertOnSubmit(objroute); DB.SubmitChanges(); } strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage GetLoction(string Token, string AccountId) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var GetLocationInfo = DB.RouteConfigMasters.FirstOrDefault(x => x.AccountId == AccountId); if (GetLocationInfo != null) { response.Content = new StringContent(JsonConvert.SerializeObject(GetLocationInfo), Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage GetRolewiseUserInformation(string Token, string Appkey, long RoleID) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var RoleInformation = DB.RoleMasters.SingleOrDefault(x => x.RoleId == RoleID); if (RoleInformation != null) { response.Content = new StringContent(JsonConvert.SerializeObject(RoleInformation), Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage VehicleLocationforAccount(string AccountId, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { List <VehicleLocation> listObjVh = new List <Controllers.VehicleLocation>(); VehicleLocation objVh; var objDevicecurrentlocations = (from objvehicalmap in DB.VehicleDeviceMapDets join objDevicecurrentlocation in DB.DeviceCurrentLocations on objvehicalmap.DeviceId equals objDevicecurrentlocation.DeviceId join objvehicles in DB.VehicleMasters on AccountId equals objvehicles.AccountId where (objvehicalmap.vehicleId == objvehicles.VehicleID) select objDevicecurrentlocation).ToList(); foreach (DeviceCurrentLocation cdeviceurrentloc in objDevicecurrentlocations) { objVh = new Controllers.VehicleLocation(); objVh.deviceCurrentLocatio = cdeviceurrentloc; objVh.vehicleId = (from objvehicalmap in DB.VehicleDeviceMapDets where (objvehicalmap.DeviceId == cdeviceurrentloc.DeviceId) select objvehicalmap.vehicleId).FirstOrDefault(); listObjVh.Add(objVh); } if (listObjVh != null) { response.Content = new StringContent(JsonConvert.SerializeObject(listObjVh), Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } else { strJson = result; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage AddUserAssociationData(UserMapDet objUserMapDet, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var CheckUserMapDetail = DB.UserMapDets.Where(x => x.PrimaryUserId == objUserMapDet.PrimaryUserId).FirstOrDefault(); if (CheckUserMapDetail == null) { UserMapDet objUserMapDets = new UserMapDet(); objUserMapDets.PrimaryUserId = objUserMapDet.PrimaryUserId; objUserMapDets.SecondaryUserId = objUserMapDet.SecondaryUserId; objUserMapDets.MapId = objUserMapDet.MapId; objUserMapDets.MappedDateTime = DateTime.Now; objUserMapDets.MappedBy = String.Format("{0}{1}", Token.Substring(0, 36), DateTime.Now.ToShortDateString()); DB.UserMapDets.InsertOnSubmit(objUserMapDets); DB.SubmitChanges(); strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"PrimaryUserId Is Already Use\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage GetCCTVDetailsbyAccountId(string AccountId, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var CCTVDetails = (from objcctvdetails in DB.CCTV_Details where objcctvdetails.AccountID == AccountId select new { AccountID = objcctvdetails.AccountID, IP = objcctvdetails.IP, Port = objcctvdetails.Port, Username = objcctvdetails.Username, Password = objcctvdetails.Password, // LastLoginDateTime= objUserLoginDets.LastLoginDateTime, // UpdatedDateTime=objUserLoginDets.UpdatedDateTime }).ToList(); if (CCTVDetails != null) { response.Content = new StringContent(JsonConvert.SerializeObject(CCTVDetails), Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage AddDeviceMasterData(DeviceMaster objDeviceMaster, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var deviceDublicate = (from dm in DB.DeviceMasters where dm.DeviceUniqueId == objDeviceMaster.DeviceUniqueId select dm).FirstOrDefault(); if (deviceDublicate == null) { DeviceMaster objDeviceMasters = new DeviceMaster(); objDeviceMasters.DeviceId = objDeviceMaster.DeviceId; objDeviceMasters.DeviceModel = objDeviceMaster.DeviceModel; objDeviceMasters.DeviceTypeId = objDeviceMaster.DeviceTypeId; objDeviceMasters.DeviceUniqueId = objDeviceMaster.DeviceUniqueId; objDeviceMasters.AccountID = objDeviceMaster.AccountID; DB.DeviceMasters.InsertOnSubmit(objDeviceMasters); DB.SubmitChanges(); strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"Device UniqId Is Already Use\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage GetLoction(string Token, string AppKey, string AccountId) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var GetLocationInfo = (from objvehical in DB.VehicleMasters join objvehicalconfig in DB.VehicleDeviceMapDets on objvehical.VehicleID equals objvehicalconfig.vehicleId join objdeviceinfo in DB.DeviceLocationHistories on objvehicalconfig.DeviceId equals objdeviceinfo.DeviceId where objvehical.AccountId == AccountId select new { VehicleID = objvehical.VehicleID, VehicleRegNo = objvehical.VehicleRegNo, Lat = objdeviceinfo.Lat, Long = objdeviceinfo.Long, }).ToList().LastOrDefault(); if (GetLocationInfo != null) { response.Content = new StringContent(JsonConvert.SerializeObject(GetLocationInfo), Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage AddAccountManagemetData(AccountManagemet objSt, string Token) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { if (objSt != null) { var checkAccountmanagment = DB.AccountManagemets.Where(x => x.AccountID == objSt.AccountID).FirstOrDefault(); if (checkAccountmanagment == null) { AccountManagemet objAccountManagemet = new AccountManagemet(); objAccountManagemet.AccountID = objSt.AccountID; objAccountManagemet.AccountName = objSt.AccountName; objAccountManagemet.UpdatedBy = String.Format("{0}{1}", Token.Substring(0, 36), DateTime.Now.ToShortDateString()); objAccountManagemet.UpdatedDateTime = DateTime.Now; objAccountManagemet.AccountDesc = objSt.AccountDesc; objAccountManagemet.AppKey = Guid.NewGuid(); DB.AccountManagemets.InsertOnSubmit(objAccountManagemet); DB.SubmitChanges(); strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"AccountID is Already Use\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } else { strJson = "{\"Result\":\"No Input request was passed in the body\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage UpdateAccountManagement(AccountManagemet objaccount, string Token, string AppKey, string AccountId) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var AccountInformation = DB.AccountManagemets.FirstOrDefault(x => x.AccountID == AccountId); if (AccountInformation != null) { AccountInformation.AccountName = objaccount.AccountName; AccountInformation.UpdatedBy = String.Format("{0}{1}", Token.Substring(0, 36), DateTime.Now.ToShortDateString()); AccountInformation.UpdatedDateTime = DateTime.Now; AccountInformation.AccountDesc = objaccount.AccountDesc; DB.SubmitChanges(); strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } else { strJson = "{\"Result\":\"Invalide Key\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage AddUsersData(UserCreate objUser, string Token) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { UserManagement objUserManagement = new UserManagement(); Guid id = Guid.NewGuid(); objUserManagement.UserId = id.ToString(); objUserManagement.UserName = objUser.UserName; objUserManagement.AccountID = objUser.AccountID; objUserManagement.RoleId = objUser.RoleId; objUserManagement.CreatedDateTime = DateTime.Now; DB.UserManagements.InsertOnSubmit(objUserManagement); DB.SubmitChanges(); UserContactDet objUserContactDet = new UserContactDet(); objUserContactDet.EmailAddress = objUser.Email; objUserContactDet.PhoneNumber = objUser.PhoneNumber; objUserContactDet.PostalAddress = objUser.Address; objUserContactDet.UserId = id.ToString(); objUserContactDet.PreferredAlert = objUser.PreferredAlert; DB.UserContactDets.InsertOnSubmit(objUserContactDet); DB.SubmitChanges(); UserLoginDet objUserLoginDet = new UserLoginDet(); objUserLoginDet.UpdatedDateTime = DateTime.Now; objUserLoginDet.Password = objUser.Password; objUserLoginDet.UserId = id.ToString(); objUserLoginDet.LastLoginDateTime = DateTime.Now; DB.UserLoginDets.InsertOnSubmit(objUserLoginDet); DB.SubmitChanges(); strJson = "{\"Result\":\"" + id + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage DisassociateDevicewithVehicle(VehicleDeviceMapDet objUserDeviceMapDet, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { VehicleDeviceMapDet objUserDeviceMapDets = new VehicleDeviceMapDet(); var objDisassociate = (from udm in DB.VehicleDeviceMapDets where objUserDeviceMapDet.vehicleId == udm.vehicleId && udm.DeviceId == objUserDeviceMapDet.DeviceId select new { udm }).FirstOrDefault(); if (objDisassociate != null) { objDisassociate.udm.IsActive = false; // objDisassociate.udm.MappedDateTime = DateTime.Now; DB.SubmitChanges(); strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage AmendVehicleStatus(VehicleMaster objVehicleMaster, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var objVehicleMasters = DB.VehicleMasters.Where(x => x.AccountId == objVehicleMaster.AccountId).FirstOrDefault(); if (objVehicleMasters != null) { VehicleMaster objvehicaldata = new VehicleMaster(); objVehicleMasters.IsActive = false; // DB.VehicleMasters.InsertOnSubmit(objVehicleMasters); DB.SubmitChanges(); strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage GetPlannedRouteDetail(string Token, string AppKey, long RouteId) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var GetLocationInfo = DB.RouteDetails.FirstOrDefault(x => x.RouteId == RouteId); var get = (from n in DB.RouteDetails where n.RouteId == RouteId select new { SeqNo = n.SeqNo, Lat = n.Lat, Long = n.Long, }).ToList(); if (GetLocationInfo != null) { response.Content = new StringContent("{\"RouteID\":" + JsonConvert.SerializeObject(GetLocationInfo.RouteId) + "," + "\"RouteDetails\":" + JsonConvert.SerializeObject(get) + "}", Encoding.UTF8, "application/json"); return(response); } strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage VehicleLocation(string VehicleId, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var objDevicecurrentlocations = (from objvehicalmap in DB.VehicleDeviceMapDets join objDevicecurrentlocation in DB.DeviceCurrentLocations on objvehicalmap.DeviceId equals objDevicecurrentlocation.DeviceId where (objvehicalmap.vehicleId == VehicleId) select objDevicecurrentlocation).ToList(); if (objDevicecurrentlocations != null) { response.Content = new StringContent(JsonConvert.SerializeObject(objDevicecurrentlocations), Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } else { strJson = result; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage CreateStudent(StudentMaster objStudentMaster, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { StudentMaster objStudentMasters = new StudentMaster(); objStudentMasters.AccountID = objStudentMaster.AccountID; objStudentMasters.Class = objStudentMaster.Class; objStudentMasters.QRCodeFileName = objStudentMaster.QRCodeFileName; objStudentMasters.QRCodeFilePath = objStudentMaster.QRCodeFilePath; objStudentMasters.RollNumber = objStudentMaster.RollNumber; objStudentMasters.Division = objStudentMaster.Division; objStudentMasters.Name = objStudentMaster.Name; objStudentMasters.StudentID = objStudentMaster.StudentID; objStudentMasters.IsDelete = objStudentMaster.IsDelete; DB.StudentMasters.InsertOnSubmit(objStudentMasters); DB.SubmitChanges(); strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage SudentvehicalMapdata(StudentList objstudentlist, string VehicalId, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); string[] StudentList = objstudentlist.StudentID.Split(','); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { StudentMaster objStudentMasters = new StudentMaster(); foreach (var item in StudentList) { StudentVehicleMapDetail objStudentVehicleMapDetail = new StudentVehicleMapDetail(); objStudentVehicleMapDetail.StudentID = (Convert.ToString(item.ToString())); objStudentVehicleMapDetail.VehicleId = VehicalId; DB.StudentVehicleMapDetails.InsertOnSubmit(objStudentVehicleMapDetail); DB.SubmitChanges(); } strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage GetRoleInformation(long RoleID) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var RoleInformation = (from objUserManagements in DB.UserManagements join objUserContactDets in DB.UserContactDets on objUserManagements.UserId equals objUserContactDets.UserId //join objUserLoginDets in DB.UserLoginDets on objUserManagements.UserName equals objUserLoginDets.UserId where objUserManagements.RoleId == RoleID select new { UserId = objUserManagements.UserId, UserName = objUserManagements.UserName, RoleId = objUserManagements.RoleId, AccountID = objUserManagements.AccountID, PhoneNumber = objUserContactDets.PhoneNumber, PostalAddress = objUserContactDets.PostalAddress, EmailAddress = objUserContactDets.EmailAddress, // LastLoginDateTime= objUserLoginDets.LastLoginDateTime, // UpdatedDateTime=objUserLoginDets.UpdatedDateTime }).ToList(); if (RoleInformation != null) { response.Content = new StringContent(JsonConvert.SerializeObject(RoleInformation), Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage CreateVehicle(VehicleMaster objVehicleMaster, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { VehicleMaster objVehicleMasters = new VehicleMaster(); objVehicleMasters.AccountId = objVehicleMaster.AccountId; objVehicleMasters.VehicleID = objVehicleMaster.VehicleID; objVehicleMasters.VehicleRegNo = objVehicleMaster.VehicleRegNo; objVehicleMasters.Make = objVehicleMaster.Make; objVehicleMasters.AccountId = objVehicleMaster.AccountId; objVehicleMasters.IsActive = true; DB.VehicleMasters.InsertOnSubmit(objVehicleMasters); DB.SubmitChanges(); strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } else { strJson = result; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage TrackeIn(InStudentTrack objInStudentTrack, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { //Accountmeg objaccountmegment = new Accountmeg(); //string result = objaccountmegment.Getresult(AppKey, Token); string result = "true"; if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { InStudentTrack objInStudentTracks = new InStudentTrack(); // objInStudentTracks.InDateTime = objInStudentTrack.InDateTime; - needto refactor this as the InDatetime will be from the server. This will not help mcuh if we implement the queing model for requests in the app. objInStudentTracks.InDateTime = DateTime.Now; objInStudentTracks.InLat = objInStudentTrack.InLat; objInStudentTracks.InLong = objInStudentTrack.InLong; objInStudentTracks.StudentId = objInStudentTrack.StudentId; DB.InStudentTracks.InsertOnSubmit(objInStudentTracks); DB.SubmitChanges(); strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage TrackeOut(OutStudentTrack objOutStudentTrack, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { //Accountmeg objaccountmegment = new Accountmeg(); //string result = objaccountmegment.Getresult(AppKey, Token); string result = "true"; if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { OutStudentTrack objOutStudentTracks = new OutStudentTrack(); //objOutStudentTracks.OutDateTime = objOutStudentTrack.OutDateTime; objOutStudentTracks.OutDateTime = DateTime.Now; objOutStudentTracks.OutLat = objOutStudentTrack.OutLat; objOutStudentTracks.OutLong = objOutStudentTrack.OutLong; objOutStudentTracks.StudentId = objOutStudentTrack.StudentId; DB.OutStudentTracks.InsertOnSubmit(objOutStudentTracks); DB.SubmitChanges(); strJson = "{\"Result\":\"204\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage GetCurrentLocation(string Token, string AppKey, string DeviceId) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var getCurrentlocation = DB.DeviceLocationHistories.Where(x => x.DeviceId == DeviceId).OrderByDescending(x => x.DateTime).FirstOrDefault(); if (getCurrentlocation != null) { response.Content = new StringContent(JsonConvert.SerializeObject(getCurrentlocation), Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } else { strJson = "{\"Result\":\"Invalide AppKey\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }
public HttpResponseMessage VehicleList(string AccountId, string Token, string AppKey) { string strJson = string.Empty; var response = this.Request.CreateResponse(HttpStatusCode.OK); try { Accountmeg objaccountmegment = new Accountmeg(); string result = objaccountmegment.Getresult(AppKey, Token); if (result == "true") { using (TTPAPIDataContext DB = new TTPAPIDataContext()) { var objVehicleMasters = DB.VehicleMasters.Where(x => x.AccountId == AccountId).ToList(); if (objVehicleMasters != null) { response.Content = new StringContent(JsonConvert.SerializeObject(objVehicleMasters), Encoding.UTF8, "application/json"); return(response); } else { strJson = "{\"Result\":\"100\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } } else { strJson = result; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } } catch (Exception ex) { strJson = "{\"Result\":\"" + ex.Message + "\"}"; response.Content = new StringContent(strJson, Encoding.UTF8, "application/json"); return(response); } }