Exemple #1
0
        public async Task <IActionResult> PutProjectSocials([FromRoute] int id, [FromBody] ProjectSocials projectSocials)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != projectSocials.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #2
0
        public async Task <IActionResult> PostProjectSocials([FromBody] ProjectSocials projectSocials)
        {
            if (!ModelState.IsValid || _context.ProjectsSocials.SingleOrDefault(ms => ms.ProjectId == projectSocials.ProjectId && ms.SocialId == projectSocials.SocialId) != null)
            {
                return(BadRequest(ModelState));
            }

            _context.ProjectsSocials.Add(projectSocials);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProjectSocials", new { id = projectSocials.Id }, projectSocials));
        }