Esempio n. 1
0
        public async Task <IActionResult> PutCustomer(long id, Customer customer)
        {
            if (id != customer.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> PutIssue(long id, Issue issue)
        {
            if (id != issue.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <IActionResult> SignUp([FromBody] SignUp model)
        {
            try
            {
                var admin = new Administrator
                {
                    FirstName = model.FirstName,
                    LastName  = model.LastName,
                    Email     = model.Email
                };

                admin.CreatePasswordWithHash(model.Password);
                _context.Administrators.Add(admin);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex) { return(new BadRequestObjectResult(ex.Message)); }

            return(new OkResult());
        }