Example #1
0
        public async Task <IActionResult> PutLog([FromRoute] int id, [FromBody] Log log)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != log.logId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #2
0
        public async Task <IActionResult> PutPaiement([FromRoute] string id, [FromBody] Paiement paiement)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != paiement.uuid)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #3
0
        public async Task <IActionResult> PutClients([FromRoute] int id, [FromBody] Clients clients)
        {
            string cliId = User.FindFirst(ClaimTypes.Email)?.Value;
            string emp   = User.FindFirst(ClaimTypes.Role)?.Value;

            if (int.Parse(cliId) == id || emp == "employer")
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (id != clients.cliId)
                {
                    return(BadRequest());
                }

                if (clients.cliPassword == null)
                {
                    clients.cliPassword = (from c in _context.clients
                                           where c.cliId == id
                                           select c.cliPassword).FirstOrDefault();
                }

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

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

                return(NoContent());
            }
            else
            {
                return(Unauthorized());
            }
        }