Ejemplo n.º 1
0
        public async Task <UserExceptionMsg> Create(string firstName, string lastName, string email, string phone)
        {
            try
            {
                if (_context.GymUsers.Any(user => user.Email == email))
                {
                    return(UserExceptionMsg.NameExists);
                }
                var newGymUser = new GymUsers()
                {
                    FirstName = firstName ?? "no info",
                    LastName  = lastName ?? "no info",
                    Email     = email,
                    Telephone = phone ?? "no info"
                };
                await _context.GymUsers.AddAsync(newGymUser);

                await _context.SaveChangesAsync();

                return(UserExceptionMsg.Success);
            }
            catch (Exception)
            {
                return(UserExceptionMsg.Error);
            }
        }
Ejemplo n.º 2
0
        private async Task <int> GetGymUserId(string email, GymadminContext context)
        {
            var gymUser = new GymUsers
            {
                Email = email
            };

            context.GymUsers.Add(gymUser);
            await context.SaveChangesAsync();

            var newlyCreatedGymUser = await context.GymUsers.FirstOrDefaultAsync(user => user.Email == email);

            return(newlyCreatedGymUser.GymUserId);
        }