Example #1
0
        public async Task <VmUser> AddNewUser(VmUser userInput)
        {
            VmUser retUser = null;


            if (!string.IsNullOrEmpty(userInput.UserEmail) && !(string.IsNullOrEmpty(userInput.UserEncyryptedKey)))
            {
                var checkUserExists = await _dbContext.User.AsNoTracking().Where(x => x.user_email == userInput.UserEmail).FirstOrDefaultAsync();

                if (checkUserExists != null)
                {
                    retUser         = new VmUser(checkUserExists);
                    retUser.Message = "User with same email id exists";
                    return(retUser);
                }
                else
                {
                    var masterKey = userInput.UserEmail.Substring(2, 4);

                    User entity = new User()
                    {
                        user_email            = userInput.UserEmail,
                        user_contact          = userInput.UserContact,
                        user_encryptedkey     = _encryption.EncryptText(userInput.UserEncyryptedKey, userInput.UserEncryptionMessage),
                        user_encryptedmessage = _encryption.EncryptText(userInput.UserEncryptionMessage, masterKey),
                        user_name             = userInput.UserName
                    };

                    var execResult = await _dbContext.User.AddAsync(entity);

                    await _dbContext.SaveChangesAsync();

                    if (execResult.Entity != null)
                    {
                        retUser = new VmUser(execResult.Entity);
                        retUser.DecryptedUserEmail = retUser.UserEmail;
                        retUser.UserEmail          = _encryption.EncryptText(retUser.DecryptedUserEmail, ATMConstants.emailEncKey);
                        retUser.Message            = "User Added Successfully";
                        return(retUser);
                    }
                }
            }
            else
            {
                retUser         = new VmUser();
                retUser.Message = "User Email and password cannot be blank";
                return(retUser);
            }

            return(retUser);
        }
Example #2
0
        public async Task <List <VmBooking> > FetchAllOrders(string userEmail)
        {
            var bookings = await _dbContext.Bookings.Where(x => x.user_name == userEmail).ToListAsync();

            var result = _dbContext.Activities.Join(bookings, a => a.activity_id, b => b.activity_id, (a, b) => new VmBooking
            {
                ActivityId         = a.activity_id,
                ActivityName       = a.activity_name,
                ActivityFee        = a.activity_fee,
                ActivityDesc       = a.activity_description,
                BookingDate        = b.booking_date,
                ActivityImage      = a.activity_image_path,
                UserEmail          = _encryption.EncryptText(b.user_name, ATMConstants.emailEncKey),
                DecryptedUserEmail = b.user_name
            }).ToList();

            return(result);
        }
        public async Task <ActionResult> VerifyTokenAsync(VMUserDetail email)
        {
            _logger.LogInformation("VerifyTokenAsync started", new object[] { email });
            try
            {
                if (!string.IsNullOrEmpty(HttpContext.Session.GetString("CurrentUser")))
                {
                    bool verificationresult = await _shopping.VerifyUserToken(email.user_email, email.userAuthID, email.Token);

                    if (verificationresult)
                    {
                        if (email.IsForgetPassword > 0)
                        {
                            return(RedirectToAction("UpdateUserPasswordView", "User", new { userEmail = _encryption.EncryptText(email.user_email, ATMConstants.emailEncKey) }));
                        }
                        else
                        {
                            await _shopping.SendBookingConfirmation(email.user_email, email.cartId);

                            return(this.View(verificationresult));
                        }
                    }
                    else
                    {
                        VMUserDetail user_details = new VMUserDetail();
                        user_details.user_email = email.user_email;
                        user_details.IsToken    = true;
                        user_details.Message    = "Invalid token";

                        return(this.View("GetUserDetails", user_details));
                    }
                }
                else
                {
                    return(View("Error"));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, new object[] { email });
                throw ex;
            }
        }