Exemple #1
0
        public async Task <IActionResult> PutUserMember([FromBody] User user)
        {
            if (user.Username == null)
            {
                return(new BadRequestObjectResult("No empty fields allowed"));
            }
            User dbUser = _context.Users.Where(u => u.Username == user.Username)
                          .FirstOrDefault <User>();

            if (dbUser == null)
            {
                return(BadRequest("User is null"));
            }
            dbUser.MemberID         = user.MemberID;
            dbUser.MemberStartDate  = user.MemberExpiryDate;
            dbUser.MemberStartDate  = dbUser.MemberStartDate.Value.AddYears(-1);
            dbUser.MemberExpiryDate = user.MemberExpiryDate;
            _context.Users.Update(dbUser);
            await _context.SaveChangesAsync();

            _notificationMessage.ConfirmationNotification(_context, dbUser);
            return(Ok("User update successful"));
        }