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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        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 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);
            }
        }
Exemplo n.º 9
0
        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 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);
            }
        }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        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);
            }
        }
Exemplo n.º 13
0
        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);
            }
        }
Exemplo n.º 14
0
        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);
            }
        }
Exemplo n.º 15
0
        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);
            }
        }
Exemplo n.º 16
0
        public HttpResponseMessage OutStudentTrack(OutStudentTrack obOutStudentTrack, 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())
                    {
                        OutStudentTrack objOutStudentTracks = new OutStudentTrack();
                        objOutStudentTracks.OutDateTime = obOutStudentTrack.OutDateTime;
                        objOutStudentTracks.OutLat      = obOutStudentTrack.OutLat;
                        objOutStudentTracks.OutLong     = obOutStudentTrack.OutLong;
                        objOutStudentTracks.StudentId   = obOutStudentTrack.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);
            }
        }
Exemplo n.º 17
0
        public HttpResponseMessage AddRouteData(Route objRouteDetail, 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())
                    {
                        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);
                    }
                }
                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);
            }
        }
Exemplo n.º 18
0
        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 AddAssociateRoutewithVehical(VehicleRouteMapDet objUserRouteMapDet, 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())
                    {
                        VehicleRouteMapDet objUserRouteMapDets = new VehicleRouteMapDet();
                        objUserRouteMapDets.RouteId         = objUserRouteMapDet.RouteId;
                        objUserRouteMapDets.VehicleId       = objUserRouteMapDet.VehicleId;
                        objUserRouteMapDets.CreatedDateTime = DateTime.Now;
                        objUserRouteMapDets.CreatedBy       = String.Format("{0}{1}", Token.Substring(0, 36), DateTime.Now.ToShortDateString());
                        objUserRouteMapDets.UpdatedBy       = String.Format("{0}{1}", Token.Substring(0, 36), DateTime.Now.ToShortDateString());
                        objUserRouteMapDets.UpdatedDateTime = DateTime.Now;
                        DB.VehicleRouteMapDets.InsertOnSubmit(objUserRouteMapDets);
                        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);
            }
        }
Exemplo n.º 20
0
        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);
            }
        }
Exemplo n.º 21
0
        public HttpResponseMessage GetListOfUser(int RoleId, 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 UserInfoByRole = DB.UserManagements.Where(x => x.RoleId == RoleId).ToList();
                        if (UserInfoByRole != null)
                        {
                            response.Content = new StringContent(JsonConvert.SerializeObject(UserInfoByRole), 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);
            }
        }
Exemplo n.º 22
0
        public HttpResponseMessage GetRolewiseUserInformation(string Token, string Appkey, long RoleID)
        {
            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 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);
                        }
                    }
                }
                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);
            }
        }
Exemplo n.º 23
0
        public HttpResponseMessage CreateRole(RoleMaster objRole, 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())
                    {
                        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, 36), DateTime.Now.ToShortDateString());
                        DB.RoleMasters.InsertOnSubmit(objRoleMaster);
                        DB.SubmitChanges();

                        strJson          = "{\"Result\":\"" + objRoleMaster.RoleId + "\"}";
                        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);
            }
        }
Exemplo n.º 24
0
        public HttpResponseMessage MapUserVehicleDet(UservehicleMapDet objUserVehicleMapDet, 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())
                    {
                        UservehicleMapDet objUserVehicleMap = new UservehicleMapDet();
                        objUserVehicleMap.UserId    = objUserVehicleMapDet.UserId;
                        objUserVehicleMap.vehicleId = objUserVehicleMapDet.vehicleId;

                        DB.UservehicleMapDets.InsertOnSubmit(objUserVehicleMap);
                        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);
            }
        }
Exemplo n.º 25
0
        public HttpResponseMessage AddDeviceTypeInformationData(DeviceTypeMaster objDeviceTypeMaster, 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())
                    {
                        DeviceTypeMaster objDeviceTypeMasters = new DeviceTypeMaster();
                        objDeviceTypeMasters.DeviceTypeDesc = objDeviceTypeMaster.DeviceTypeDesc;
                        DB.DeviceTypeMasters.InsertOnSubmit(objDeviceTypeMasters);
                        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);
            }
        }
Exemplo n.º 26
0
        public HttpResponseMessage GetForgetPassword(string UserName, string Email, 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 ForgetPassword = DB.UserManagements.Where(x => x.UserName == UserName).FirstOrDefault();
                        if (ForgetPassword != null)
                        {
                            UserLoginDet objUserLoginDet = new UserLoginDet();
                            var          userdata        = DB.UserLoginDets.Where(x => x.UserId == ForgetPassword.UserId).FirstOrDefault();
                            Random       rng             = new Random();
                            int          Password        = rng.Next(1000, 100000000);
                            //  string Password = rng.Next(10).ToString();
                            userdata.Password = Password.ToString();
                            DB.SubmitChanges();
                            SmtpClient smtp = new SmtpClient(ConfigurationManager.AppSettings["SMTP"], Convert.ToInt32(ConfigurationManager.AppSettings["PORT"]));
                            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                            smtp.Credentials    = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["FromEmail"].ToString(), ConfigurationManager.AppSettings["Password"].ToString());

                            string      fromEmail = ConfigurationManager.AppSettings["FromEmail"].ToString();
                            string      toEmail   = Email;
                            MailMessage message   = new MailMessage();
                            message.To.Add(toEmail);
                            message.From       = new MailAddress(fromEmail, "TTPA");
                            message.IsBodyHtml = true;
                            message.Subject    = "Send Password";
                            message.Body       = "Hello, <br />";
                            message.Body      += "Email Id : " + Email;
                            message.Body      += "User Name: " + UserName;
                            message.Body      += "<br />Your Password Is: " + Password;
                            message.Body      += "<br />Thank You.";
                            smtp.Send(message);
                            strJson          = "{\"Result\":\"Password is sent to your mail.\"}";
                            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\":\"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 GetListAssociations(string Token, string AppKey, string UserId)
        {
            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 UserList = (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 objvehicaldetail in DB.VehicleDeviceMapDets on objvehicalmaster.VehicleID equals objvehicaldetail.vehicleId
                                        join objdeviceinfo in DB.DeviceMasters on objvehicaldetail.DeviceId equals objdeviceinfo.DeviceId into g
                                        join objRouteConfigMaster in DB.RouteConfigMasters on objvehicalmaster.AccountId equals objRouteConfigMaster.AccountId
                                        join objRoute in DB.RouteDetails on objRouteConfigMaster.RouteId equals objRoute.RouteId into routinelist
                                        join objUserLoginDets in DB.UserLoginDets on objUserManagements.UserId equals objUserLoginDets.UserId
                                        where objUserManagements.UserId == UserId
                                        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,
                            DeviceList = g.ToList(),
                            RouteList = routinelist.ToList(),
                            // Password = objUserLoginDets.Password,
                            //  LastLoginDateTime=  objUserLoginDets.LastLoginDateTime,
                            //   UpdatedDateTime=objUserLoginDets.UpdatedDateTime
                        }).ToList();
                        ////   var userlist = DB.UserLoginDets.ToList();
                        //   var routelist = DB.UserRouteMapDets.ToList();
                        //   var userdevic = DB.UserDeviceMapDets.ToList();
                        if (UserList != null)
                        {
                            //response.Content = new StringContent("{\"UserList\":" +
                            //                                          JsonConvert.SerializeObject(UserList) + "," + "\"Routelist\":" + JsonConvert.SerializeObject(routelist) + "," + "\"Userdevice\":" + JsonConvert.SerializeObject(userdevic) + "}", Encoding.UTF8, "application/json");
                            //return response;


                            response.Content = new StringContent(JsonConvert.SerializeObject(UserList), 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);
            }
        }
Exemplo n.º 28
0
        public HttpResponseMessage UpdateProfile(UserCreate objUser, 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())
                    {
                        UserManagement objUserManagement = new UserManagement();
                        var            checkuser         = DB.UserManagements.Where(x => x.UserId == objUser.UserId).FirstOrDefault();
                        if (checkuser != null)
                        {
                            checkuser.UserName        = objUser.UserName;
                            checkuser.AccountID       = objUser.AccountID;
                            checkuser.RoleId          = objUser.RoleId;
                            checkuser.CreatedDateTime = DateTime.Now;
                            // DB.UserManagements.InsertOnSubmit(objUserManagement);
                            DB.SubmitChanges();

                            UserContactDet objUserContactDet = new UserContactDet();
                            var            objusercontact    = DB.UserContactDets.Where(x => x.UserId == objUser.UserId).FirstOrDefault();
                            objusercontact.EmailAddress   = objUser.Email;
                            objusercontact.PhoneNumber    = objUser.PhoneNumber;
                            objusercontact.PreferredAlert = objUser.PreferredAlert;
                            objusercontact.PostalAddress  = objUser.Address;
                            DB.SubmitChanges();

                            UserLoginDet objUserLoginDet = new UserLoginDet();
                            var          objloginDet     = DB.UserLoginDets.Where(x => x.UserId == objUser.UserId).FirstOrDefault();
                            objloginDet.UpdatedDateTime = DateTime.Now;
                            objloginDet.Password        = objUser.Password;
                            //objUserLoginDet.LastLoginDateTime = DateTime.Now;
                            //  DB.UserLoginDets.InsertOnSubmit(objUserLoginDet);
                            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);
            }
        }