Exemplo n.º 1
0
        //学校详情
        public SchoolResponse Detail(int id)
        {
            SchoolResponse response = null;

            try
            {
                var school = _dbContext.Get <t_sys_school>(id);
                if (school != null)
                {
                    response = new SchoolResponse {
                        Id          = school.id,
                        CityId      = school.cityId,
                        CreateTime  = school.createtime,
                        UpdateTime  = school.updatetime,
                        IsDelete    = school.isdelete,
                        ChinessName = school.chinessname,
                        EnglishName = school.englishname,
                        isInter     = school.isInter,
                        ProvinceId  = school.provinceId
                    };
                }
            }
            catch (Exception ex)
            {
                LogUtils.LogError("SchoolService.Detail", ex);
            }
            return(response);
        }
Exemplo n.º 2
0
        public SchoolResponse Map(School school)
        {
            if (school == null)
            {
                return(null);
            }

            var schoolResponse = new SchoolResponse
            {
                Id          = school.Id,
                Name        = school.Name,
                Country     = school.Country,
                HasSeasons  = school.SchoolOwnsSeason.Select(x => x.Season?.Name),
                HasTeachers = school.Teacher.Select(HelperMapper.BasicMap)
            };

            return(schoolResponse);
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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));
        }