예제 #1
0
        public UserDatasetDTO AddUserDataset(UserDatasetDTO dto, string userId)
        {
            var NewDS = ReadDTO(dto);

            NewDS.OwnerId = userId;

            //var project = _projectRepository.FindSingle(p => p.Accession == dto.ProjectAcc);
            NewDS.ProjectId = dto.ProjectId;
            NewDS.Id        = Guid.NewGuid();

            var addedUserDataset = _userDatasetRepository.Insert(NewDS);

            if (!_unitOfWork.Save().Equals("CREATED"))
            {
                return(null);
            }
            dto.Id = addedUserDataset.Id.ToString();
            return(dto);
        }
예제 #2
0
        public IActionResult AddUserDataset([FromBody] UserDatasetDTO dto)
        {
            UserDatasetDTO addedUserDataset = null;

            if (!User.Identity.IsAuthenticated)
            {
                return(null);
            }
            var userId = User.FindFirst(ClaimTypes.UserData).Value;

            addedUserDataset = _userDataService.AddUserDataset(dto, userId);

            if (addedUserDataset != null)
            {
                return(new CreatedAtActionResult("GET", "GetUserDatasetById", new { datasetId = addedUserDataset.Id }, addedUserDataset));
            }

            return(new StatusCodeResult(StatusCodes.Status409Conflict));
        }
예제 #3
0
        private UserDataset ReadDTO(UserDatasetDTO dto, UserDataset copyInto = null)
        {
            UserDataset ds;

            ds = copyInto ?? new UserDataset();

            ds.Name        = dto.Name;
            ds.Description = dto.Description;
            ds.Tags        = dto.Tags;
            //ds.OwnerId = dto.OwnerId;
            //ds.ProjectId = dto.ProjectId;
            ds.Type         = dto.Type;
            ds.LastModified = DateTime.Now.ToString("d");// ToShortDateString();

            ds.Filters = new List <DataFilter>();
            //ds.Fields = new List<DataField>();
            foreach (var filterDto in dto.Filters)
            {
                if (filterDto.IsNumeric)
                {
                    var filter = new DataFilterRange();
                    filter.DataField  = getDataField(filterDto.Field);
                    filter.Lowerbound = filterDto.From;
                    filter.Upperbound = filterDto.To;
                    ds.Filters.Add(filter);
                }
                else
                {
                    var filter = new DataFilterExact();
                    filter.DataField = getDataField(filterDto.Field);
                    filter.Values    = filterDto.FilterValues;
                    ds.Filters.Add(filter);
                }
            }

            foreach (var fieldDto in dto.Fields)
            {
                // ds.Fields.Add(getDataField(fieldDto));
            }
            return(ds);
        }