예제 #1
0
        public async Task <int> Post(College4GTestView view)
        {
            var college = _collegeRepository.GetByName(view.CollegeName);

            if (college == null)
            {
                return(0);
            }
            view.TestTime = DateTime.Today.AddHours(DateTime.Now.Hour);
            var result =
                _repository.FirstOrDefault(
                    x => x.TestTime == view.TestTime && x.CollegeId == college.Id && x.Place == view.Place);

            if (result != null)
            {
                Mapper.Map(view, result);
            }
            else
            {
                result = view.MapTo <College4GTestResults>();
            }
            result.CollegeId = college.Id;
            var fields = view.CellName.GetSplittedFields('-');

            if (fields.Length > 1)
            {
                var eNodeb = _eNodebRepository.GetByName(fields[0]);
                if (eNodeb != null)
                {
                    result.ENodebId = eNodeb.ENodebId;
                    result.SectorId = fields[1].ConvertToByte(0);
                }
            }
            await _repository.InsertOrUpdateAsync(result);

            return(_repository.SaveChanges());
        }
        public async Task <int> Post(College4GTestResults result)
        {
            await _repository.InsertOrUpdateAsync(result);

            return(_repository.SaveChanges());
        }