コード例 #1
0
        public HttpResponseMessage GetStates(string securityToken, string countryCode)
        {
            StatesResponse response = null;

            if (IsValid(securityToken))
            {
                ICommon commonSvc = new CommonService(this._dbContext);
                response = new StatesResponse {
                    Status = "OK"
                };
                response.States = commonSvc.FindStates(countryCode);

                if (null == response.States)
                {
                    response.Status       = "Error";
                    response.ErrorMessage = string.Format("States not found for country: {0}", countryCode);
                    CurrentLoggerProvider.Info(response.ErrorMessage);
                }
                else
                {
                    CurrentLoggerProvider.Info(string.Format("Retrieved States for Country: {0}", countryCode));
                }
            }
            else
            {
                response = new StatesResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info("Invalid Request");
            }

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #2
0
        public HttpResponseMessage GetTimeTable(string securityToken, int schoolId, int classId, int sectionId)
        {
            TimeTableVMResponse response = null;

            if (IsValid(securityToken))
            {
                ITimeTable ttService = new TimeTableService(this._dbContext);
                response = new TimeTableVMResponse {
                    Status = "OK"
                };
                response.Monday     = ttService.Get(schoolId, classId, sectionId, "Monday");
                response.Tuesday    = ttService.Get(schoolId, classId, sectionId, "Tuesday");
                response.Wednessday = ttService.Get(schoolId, classId, sectionId, "Wednessday");
                response.Thursday   = ttService.Get(schoolId, classId, sectionId, "Thursday");
                response.Friday     = ttService.Get(schoolId, classId, sectionId, "Friday");

                CurrentLoggerProvider.Info("Retrieved time for mobile view");
            }
            else
            {
                response = new TimeTableVMResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info("Invalid Request");
            }

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #3
0
        public HttpResponseMessage Get(string securityToken, int schoolId)
        {
            TTCommonResponse response = null;

            if (IsValid(securityToken))
            {
                ITimeTable ttService = new TimeTableService(this._dbContext);
                response = new TTCommonResponse {
                    Status = "OK"
                };
                response.Subjects = ttService.GetSubjects(schoolId);
                response.Lectures = ttService.GetLectures(schoolId);

                CurrentLoggerProvider.Info(string.Format("Retrieved Common Data. Subjects: {0}, Lectures: {1}", response.Subjects.Count(), response.Lectures.Count()));
            }
            else
            {
                response = new TTCommonResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info("Invalid Request");
            }

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #4
0
        public HttpResponseMessage GetAll(string securityToken)
        {
            MasterDataResponse response = null;

            if (IsValid(securityToken))
            {
                ICommon commonSvc = new CommonService(this._dbContext);
                response = new MasterDataResponse {
                    Status = "OK"
                };
                response.Classes    = commonSvc.GetAllClasses();
                response.Sections   = commonSvc.GetAllSections();
                response.TagDetails = commonSvc.GetAllTags();
                response.Coutries   = commonSvc.GetAllCountries();
                response.States     = commonSvc.GetAllStates();
                response.Subjects   = commonSvc.GetAllSubjects();
                CurrentLoggerProvider.Info(string.Format("Retrieved Master Data"));
            }
            else
            {
                response = new MasterDataResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info("Invalid Request");
            }

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #5
0
        public HttpResponseMessage UploadFile()
        {
            CommonService    commonSvc = new CommonService(this._dbContext);
            DocumentResponse res       = new DocumentResponse {
                Status = "OK"
            };
            var SecurityToken = System.Web.HttpContext.Current.Request.Form["SecurityToken"];

            if (IsValid(SecurityToken))
            {
                //var studentSvc = new NotificationService(this._dbContext);
                var result = commonSvc.UploadDocument();
                res.ErrorMessage = result.ReasonPhrase;
                //studentSvc.Save(req.Notification);
            }
            else
            {
                res = new DocumentResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info(string.Format("Invalid Request. Student Id: {0}", 0));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, res));
            //FileUploadResponse response = null;
            //var securityToken = System.Web.HttpContext.Current.Request.Form["SecurityToken"];
            //if (IsValid(securityToken))
            //{
            //    ICommon commonSvc = new CommonService(this._dbContext);
            //    response = new FileUploadResponse { Status = "OK" };

            //        var result = SaveFile();

            //    response.ErrorMessage = result.ReasonPhrase;

            //}
            //else
            //{
            //    response = new FileUploadResponse { Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token" };
            //    CurrentLoggerProvider.Info("Invalid Request");
            //}

            //return Request.CreateResponse(HttpStatusCode.OK, response);
        }
コード例 #6
0
        public HttpResponseMessage Get(string securityToken, int Id)
        {
            OrganizationResponse response = null;

            if (IsValid(securityToken))
            {
                IOrganization org = new OrganizationService(this._dbContext);

                response = new OrganizationResponse {
                    Status = "OK"
                };
                try
                {
                    response.Organization = org.Get(Id);
                    if (null == response.Organization)
                    {
                        response.ErrorCode    = "ERR1002";
                        response.ErrorMessage = string.Format("Invalid Organization Id: {0}", Id);
                        response.Status       = "Error";
                        CurrentLoggerProvider.Error(string.Format("Invalid Request. Organization Id: {0}", Id));
                    }
                    else
                    {
                        CurrentLoggerProvider.Info(string.Format("Retrieved Organization. Id = {0}, Name={1}", response.Organization.ID, response.Organization.Name));
                    }
                }
                catch (Exception e)
                {
                    CurrentLoggerProvider.Error(string.Format("Error whiling retrieving Organization. Id = {0}", Id), e);
                    response.ErrorCode    = "ERR1003";
                    response.ErrorMessage = string.Format("Unable to process request due to technical issue(s). Organization Id: {0}", Id);
                    response.Status       = "Error";
                }
            }
            else
            {
                response = new OrganizationResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
            }
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #7
0
        public HttpResponseMessage Get(string securityToken, int Id)
        {
            SchoolResponse response = null;

            if (IsValid(securityToken))
            {
                ISchool schools = new StudentTracking.Application.Main.SchoolService(this._dbContext);
                response = new SchoolResponse {
                    Status = "OK"
                };
                try
                {
                    response.School = schools.Get(Id);
                    if (null == response.School)
                    {
                        response.ErrorCode    = "ERR1002";
                        response.ErrorMessage = string.Format("Invalid School Id: {0}", Id);
                        response.Status       = "Error";
                        CurrentLoggerProvider.Error(string.Format("Invalid Request. School Id: {0}", Id));
                    }
                    else
                    {
                        CurrentLoggerProvider.Info(string.Format("Retrieved School. Id = {0}, Name={1}", response.School.Id, response.School.Name));
                    }
                }
                catch (Exception e)
                {
                    CurrentLoggerProvider.Error(string.Format("Error whiling retrieving School. Id = {0}", Id), e);
                    response.ErrorCode    = "ERR1003";
                    response.ErrorMessage = string.Format("Unable to process request due to technical issue(s). School Id: {0}", Id);
                    response.Status       = "Error";
                }
            }
            else
            {
                response = new SchoolResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info(string.Format("Invalid Request. School Id: {0}", Id));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #8
0
        public HttpResponseMessage Save(StaffRequest req)
        {
            StaffResponse res = new StaffResponse {
                Status = "OK"
            };

            if (IsValid(req.SecurityToken))
            {
                var studentSvc = new StaffService(this._dbContext);
                res.Staff = studentSvc.Save(req.Staff);
            }
            else
            {
                res = new StaffResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info(string.Format("Invalid Request. Student Id: {0}", req.Staff.StaffId));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, res));
        }
コード例 #9
0
        public HttpResponseMessage Save(UserRequest req)
        {
            UserResponse response = new UserResponse {
                Status = "OK"
            };

            if (isValid(req.SecurityToken))
            {
                ISecurity securitySvc = new SecurityService(this.__dbContext);
                response.User = securitySvc.Save(req.User);
            }
            else
            {
                response = new UserResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info(string.Format("Invalid Request. Security Token: {0}", req.SecurityToken));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #10
0
        public HttpResponseMessage Save(SchoolSaveRequest request)
        {
            SchoolResponse response = new SchoolResponse {
                Status = "OK"
            };

            if (IsValid(request.SecurityToken))
            {
                var schoolSvc = new SchoolService(this._dbContext);
                response.School = schoolSvc.Save(request.School);
            }
            else
            {
                response = new SchoolResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info(string.Format("Invalid Request. School Id: {0}", request.School.Id));
            }


            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #11
0
        public HttpResponseMessage GetAll(string securityToken, int schoolId)
        {
            UsersResponse response = new UsersResponse();

            if (isValid(securityToken))
            {
                ISecurity securitySvc = new SecurityService(this.__dbContext);
                response = new UsersResponse {
                    Status = "OK"
                };
                response.Users = securitySvc.UsersList(schoolId);
            }
            else
            {
                response = new UsersResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info(string.Format("Invalid Request. Security Token: {0}", securityToken));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #12
0
        public HttpResponseMessage Get(string securityToken)
        {
            AllSchoolsResponse response = null;

            if (IsValid(securityToken))
            {
                ISchool school = new SchoolService(this._dbContext);
                response = new AllSchoolsResponse {
                    Status = "OK"
                };
                response.Schools = school.GetAll();
                CurrentLoggerProvider.Info(string.Format("Retrieved Schools. Count = {0}", response.Schools.Count()));
            }
            else
            {
                response = new AllSchoolsResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info("Invalid Request. School Id: {0}");
            }

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #13
0
        public HttpResponseMessage getEvents(string securityToken, int schoolId)
        {
            EventResponse response = null;

            if (IsValid(securityToken))
            {
                ISchool school = new SchoolService(this._dbContext);
                response = new EventResponse {
                    Status = "OK"
                };
                response.Events = school.GetEvents(schoolId);
                CurrentLoggerProvider.Info(string.Format("Retrieved Events: {0}", response.Events != null ? response.Events.Count() : 0));
            }
            else
            {
                response = new EventResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info(string.Format("Invalid Request. School Id: {0}", schoolId));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #14
0
        public HttpResponseMessage Get(string securityToken, int schoolId, int classId, int sectionId)
        {
            AllStudentResponse response = null;

            if (IsValid(securityToken))
            {
                IStudentDetails student = new StudentService(this._dbContext);
                response = new AllStudentResponse {
                    Status = "OK"
                };
                response.Students = student.Find(schoolId, classId, sectionId);
                CurrentLoggerProvider.Info(string.Format("Retrieved Student Details. Count = {0}", response.Students.Count()));
            }
            else
            {
                response = new AllStudentResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info("Invalid Request. Student Id: {0}");
            }

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #15
0
        public HttpResponseMessage Get(string securityToken)
        {
            OrganizationsResponse response = null;

            if (IsValid(securityToken))
            {
                IOrganization org = new OrganizationService(this._dbContext);

                response = new OrganizationsResponse {
                    Status = "OK"
                };
                response.Organizations = org.GetAll();
                CurrentLoggerProvider.Info(string.Format("Retrieved Organizations. Count = {0}", response.Organizations.Count()));
            }
            else
            {
                response = new OrganizationsResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
            }

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #16
0
        public HttpResponseMessage Get(string securityToken, int schoolId, string userId)
        {
            NotificationResponse response = null;

            if (IsValid(securityToken))
            {
                INotificationService notificationService = new NotificationService(this._dbContext);
                response = new NotificationResponse {
                    Status = "OK"
                };
                response.Notifications = notificationService.Get(schoolId, userId);

                CurrentLoggerProvider.Info(string.Format("Retrieved Notifications. Count = {0}", response.Notifications.Count()));
            }
            else
            {
                response = new NotificationResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info("Invalid Request");
            }

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #17
0
        public HttpResponseMessage Get(string securityToken, int schoolId, int classId, int sectionId)
        {
            TimeTableResponse response = null;

            if (IsValid(securityToken))
            {
                ITimeTable ttService = new TimeTableService(this._dbContext);
                response = new TimeTableResponse {
                    Status = "OK"
                };
                response.TimeTables = ttService.FindAll(schoolId, classId, sectionId);

                CurrentLoggerProvider.Info(string.Format("Retrieved Time Table. Count = {0}", response.TimeTables.Count()));
            }
            else
            {
                response = new TimeTableResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info("Invalid Request");
            }

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #18
0
        public HttpResponseMessage Save()
        {
            var studentSvc = new NotificationService(this._dbContext);
            NotificationSaveResponse res = new NotificationSaveResponse {
                Status = "OK"
            };
            var SecurityToken = System.Web.HttpContext.Current.Request.Form["SecurityToken"];

            if (IsValid(SecurityToken))
            {
                //var studentSvc = new NotificationService(this._dbContext);
                var result = studentSvc.PostFormData();
                res.ErrorMessage = result.ReasonPhrase;
                //studentSvc.Save(req.Notification);
            }
            else
            {
                res = new NotificationSaveResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info(string.Format("Invalid Request. Student Id: {0}", 0));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, res));
        }
コード例 #19
0
        public HttpResponseMessage Get(string securityToken, int schoolId, int classId)
        {
            SyllabusResponse response = null;

            if (IsValid(securityToken))
            {
                ISyllabusService syllabusService = new SyllabusService(this._dbContext);
                response = new SyllabusResponse {
                    Status = "OK"
                };
                response.Syllabus = syllabusService.Get(schoolId, classId);

                CurrentLoggerProvider.Info(string.Format("Retrieved Syllabus. Count = {0}", response.Syllabus.Count()));
            }
            else
            {
                response = new SyllabusResponse {
                    Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token"
                };
                CurrentLoggerProvider.Info("Invalid Request");
            }

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }