Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostInsertCodeAsync(IFormFile upload)
        {
            TMSDto tMSDto = new TMSDto();

            if (upload.FileName.EndsWith(".csv"))
            {
                using (var sreader = new StreamReader(upload.OpenReadStream()))
                {
                    string[] headers = sreader.ReadLine().Split(',');     //Title
                    while (!sreader.EndOfStream)                          //get all the content in rows
                    {
                        string[] rows = sreader.ReadLine().Split(',');
                        tMSDto.TaskID     = int.Parse(rows[0].ToString());
                        tMSDto.TaskName   = rows[1].ToString();
                        tMSDto.Assignee   = rows[2].ToString();
                        tMSDto.TimeSpent  = float.Parse(rows[3].ToString());
                        tMSDto.TaskGroup  = int.Parse(rows[4].ToString());
                        tMSDto.TaskStatus = int.Parse(rows[5].ToString());
                        var newTms = await _tmsRepository.Create(tMSDto);
                    }
                }
            }

            //var newTms = await _tmsRepository.Create(tMSDto);
            //return CreatedAtAction(nameof(GetTms), new { id = newTms.TaskID }, newTms);
            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <TMSDto> Create(TMSDto tms)
        {
            _dbhelpercontext.TMSDto.Add(tms);
            await _dbhelpercontext.SaveChangesAsync();

            //throw new NotImplementedException();
            return(tms);
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> PutTMS(int id, [FromBody] TMSDto tMSDto)
        {
            if (id != tMSDto.TaskID)
            {
                return(BadRequest());
            }
            await _tmsRepository.Update(tMSDto);

            return(NoContent());
        }
Ejemplo n.º 4
0
        public async Task <ActionResult <TMSDto> > PostTMS([FromBody] TMSDto tMSDto)
        {
            var newTms = await _tmsRepository.Create(tMSDto);

            return(CreatedAtAction(nameof(GetTms), new { id = newTms.TaskID }, newTms));
        }
Ejemplo n.º 5
0
 public async Task Update(TMSDto tms)
 {
     _dbhelpercontext.Entry(tms).State = EntityState.Modified;
     await _dbhelpercontext.SaveChangesAsync();
 }