Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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 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);
            }
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
        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 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 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 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 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 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);
            }
        }
Esempio n. 13
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);
            }
        }
Esempio n. 14
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);
            }
        }
Esempio n. 15
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);
            }
        }
Esempio n. 16
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);
            }
        }
Esempio n. 17
0
        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);
            }
        }
Esempio n. 18
0
        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 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);
            }
        }
Esempio n. 20
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);
            }
        }
Esempio n. 21
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);
            }
        }
Esempio n. 22
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);
            }
        }
Esempio n. 23
0
        public HttpResponseMessage AddPostLocation(string Lat, string Long, DateTime DateTime, string Typeofnetwork, 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);
                string result = "true";
                if (result == "true")
                {
                    using (TTPAPIDataContext DB = new TTPAPIDataContext())
                    {
                        DeviceLocationHistory objDeviceLocationHistory = new DeviceLocationHistory();
                        DeviceCurrentLocation objDevicecurrentlocation = new DeviceCurrentLocation();
                        objDeviceLocationHistory.DeviceId      = DeviceId;
                        objDeviceLocationHistory.Lat           = Lat;
                        objDeviceLocationHistory.Long          = Long;
                        objDeviceLocationHistory.DateTime      = DateTime;
                        objDeviceLocationHistory.Typeofnetwork = Typeofnetwork;
                        DB.DeviceLocationHistories.InsertOnSubmit(objDeviceLocationHistory);
                        DB.SubmitChanges();
                        var objcurrentlocation = DB.DeviceCurrentLocations.Where(x => x.DeviceId == DeviceId).FirstOrDefault();
                        if (objcurrentlocation == null)
                        {
                            objDevicecurrentlocation.CurrentLat     = Lat;
                            objDevicecurrentlocation.CurrentLong    = Long;
                            objDevicecurrentlocation.DeviceId       = DeviceId;
                            objDevicecurrentlocation.UpatedDateTime = DateTime;
                            DB.DeviceCurrentLocations.InsertOnSubmit(objDevicecurrentlocation);
                            DB.SubmitChanges();
                        }
                        else
                        {
                            objcurrentlocation.CurrentLat     = Lat;
                            objcurrentlocation.CurrentLong    = Long;
                            objcurrentlocation.DeviceId       = DeviceId;
                            objcurrentlocation.UpatedDateTime = DateTime;
                            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);
            }
        }
Esempio n. 24
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);
            }
        }
Esempio n. 25
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);
            }
        }
Esempio n. 26
0
        public HttpResponseMessage GetLogin(string Email, string Password, Guid AppKey)
        {
            string strJson  = string.Empty;
            var    response = this.Request.CreateResponse(HttpStatusCode.OK);

            try
            {
                using (TTPAPIDataContext DB = new TTPAPIDataContext())
                {
                    UserManagement objuser     = new UserManagement();
                    var            appKeycheck = DB.AccountManagemets.Where(x => x.AppKey == AppKey).FirstOrDefault();
                    if (appKeycheck != null)
                    {
                        var logininformation = (from objUserContactDets in DB.UserContactDets
                                                join objUserLoginDet in DB.UserLoginDets on objUserContactDets.UserId equals objUserLoginDet.UserId
                                                join objUserManagement in DB.UserManagements on objUserContactDets.UserId equals objUserManagement.UserId
                                                join objaccount in DB.AccountManagemets on objUserManagement.AccountID equals objaccount.AccountID
                                                where objUserContactDets.EmailAddress == Email && objUserLoginDet.Password == Password && objaccount.AppKey == AppKey
                                                select new
                        {
                            UserId = objUserManagement.UserId,
                            Token = String.Format("{0}{1}{2}", objUserManagement.UserId.ToString(), Convert.ToString(objUserManagement.AccountID), Convert.ToString(objUserManagement.RoleId)),
                        }).FirstOrDefault();
                        if (logininformation != null)
                        {
                            AccessTokenCache objAccessTokenCache = new AccessTokenCache();
                            var checkappkey = DB.AccessTokenCaches.Where(x => x.Token == logininformation.Token).FirstOrDefault();
                            if (checkappkey == null)
                            {
                                objAccessTokenCache.UserId             = logininformation.UserId;
                                objAccessTokenCache.Token              = logininformation.Token;
                                objAccessTokenCache.LastAccessDateTime = DateTime.Now;
                                DB.AccessTokenCaches.InsertOnSubmit(objAccessTokenCache);
                                DB.SubmitChanges();
                            }
                            strJson          = "{\"Token\":\"" + logininformation.Token + "\"}";
                            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);
            }
        }