public async Task <IActionResult> PutTimesheet(int id, Timesheet timesheet)
        {
            if (id != timesheet.TimesheetId)
            {
                return(BadRequest());
            }

            _context.Entry(timesheet).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TimesheetExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #2
0
        public async Task <IActionResult> PutUtilisateur(int id, Utilisateur utilisateur)
        {
            if (id != utilisateur.UtilisateurId)
            {
                return(BadRequest());
            }

            _context.Entry(utilisateur).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UtilisateurExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <bool> UpdateItem(ProjectItem projectItem)
        {
            var parent = await GetValidParentAsync(projectItem);

            if (parent == null)
            {
                return(false);
            }

            _context.Entry(projectItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                await _projectStatusesService.UpdateProjectStatusesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProjectItemExists(projectItem.Id))
                {
                    throw new NotFoundException();
                }
                else
                {
                    throw;
                }
            }
            return(true);
        }
        public async Task <ActionResult <Utilisateur> > RegisterUtilisateur(Utilisateur utilisateur)
        {
            _context.Utilisateurs.Add(utilisateur);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetUtilisateur", new { id = utilisateur.UtilisateurId }, utilisateur));
        }
Exemple #5
0
        public async Task <IActionResult> OnPost([FromBody] Project project)
        {
            await _context.Projects.AddAsync(project);

            await _context.SaveChangesAsync();

            //await _publishEndpoint.Publish<Project>(new
            //{
            //    Value = project
            //});
            var channel = rabbitMQ.GetChannel;

            byte[] messageBodyBytes = System.Text.Encoding.UTF8.GetBytes("Project Created!");
            channel.BasicPublish("lmsa", "", null, messageBodyBytes);

            return(Created(Url.ActionLink(nameof(OnGet), null, new
            {
                id = project.Id
            }), project));
        }