//This Action is called from the initial shopping cart page
        //The user will click this when they are ready to purchase their products
        //It will return 1 of 2 views, depending on the users' login status
        public IActionResult PaymentAuthentication(string orders)
        {
            //First check if there are any orders. If not, nothing should happen. Refresh the page
            if (orders == null)
            {
                return(RedirectToAction("ShoppingCart", "ShoppingCart"));
            }

            //Retrieve the user status to check whether the user is logged in or not
            UserStatusModel userStatus = SessionController.CheckLoggedInStatus(this.HttpContext);

            //Put the orders in the browser session. This refreshes the list, so if the user has altered their shopping cart, it'll always be up to date when entering the ordering sequence
            SessionController.refreshOrderList(orders, this.HttpContext);



            if (userStatus.LoggedIn)
            {
                //User is logged in already, so return the PaymentMethod view
                List <OfferedLabourerService> olsList = ParseOrdersToOLS();

                tbl_userdata user = MollShopContext.FindUserById((int)this.HttpContext.Session.GetInt32("UserId"));
                Tuple <List <OfferedLabourerService>, tbl_userdata> tuple = Tuple.Create(olsList, user);

                return(View("OrderSpecification", tuple));
            }

            else
            {
                //User is not logged in. return the PaymentAuthentication view
                return(View());
            }
        }
        public IActionResult Detail(int id)
        {
            if (id <= 0)
            {
                return(RedirectToNotFoundPage());
            }

            try
            {
                var status = _userStatusService.Find(id);
                if (status == null)
                {
                    return(RedirectToNotFoundPage());
                }

                var model = new UserStatusModel()
                {
                    Id          = status.Id,
                    Name        = status.Name,
                    Description = status.Description
                };
                return(View(model));
            }
            catch (Exception)
            {
                return(RedirectToErrorPage());
            }
        }
        public IActionResult Update(int id)
        {
            var status = _userStatusService.Find(id);
            var model  = new UserStatusModel()
            {
                Id          = status.Id,
                Name        = status.Name,
                Description = status.Description
            };

            return(View(model));
        }
Пример #4
0
        /// Retrieves all user settings and accomplishments and metadata about user and accomplishments,
        /// can also optionally acknowledge all accomplishments before it returns.
        public static bool GetAccomplishmentsAndSettings(UserStatusModel statusModel, User user, bool acknowledgeAccomplishments)
        {
            var saveToDb            = false;
            var userAccomplishments = new List <UserAccomplishmentModel>();

            if (acknowledgeAccomplishments)
            {
                var accomplishmentsToAcknowledge = user.UserAccomplishments.Where((ua) => !ua.IsAcknowledged).ToList();
                if (accomplishmentsToAcknowledge.Count > 0)
                {
                    foreach (var userAccomplishment in accomplishmentsToAcknowledge)
                    {
                        userAccomplishment.IsAcknowledged = true;
                        userAccomplishment.IsDirty        = true;
                    }
                    saveToDb = true;
                }
            }

            foreach (var userAccomplishment in user.UserAccomplishments.OrderBy(ua => ua.CreatedOn))
            {
                userAccomplishments.Add(userAccomplishment.ToModel());
            }
            statusModel.UserAccomplishments = userAccomplishments.ToArray();

            statusModel.HasNewExperience     = user.UserAccomplishments.FirstOrDefault((ua) => ua.Type == UserAccomplishmentTypes.ExperienceAccomplishmentId && !ua.IsAcknowledged) != null;
            statusModel.NewExperienceAmount  = user.UserAccomplishments.Where((ua) => ua.Type == UserAccomplishmentTypes.ExperienceAccomplishmentId && !ua.IsAcknowledged).Sum((ua) => ua.EarnedExperience);
            statusModel.IsNewLevel           = user.UserAccomplishments.FirstOrDefault((ua) => ua.Type == UserAccomplishmentTypes.LevelAccomplishmentId && !ua.IsAcknowledged) != null;
            statusModel.HasNewPrivilege      = user.UserAccomplishments.FirstOrDefault((ua) => ua.Type == UserAccomplishmentTypes.PrivilegeAccomplishmentId && !ua.IsAcknowledged) != null;
            statusModel.NewPrivilegeCount    = user.UserAccomplishments.Where((ua) => ua.Type == UserAccomplishmentTypes.PrivilegeAccomplishmentId && !ua.IsAcknowledged).Count();
            statusModel.HasNewAccomplishment = statusModel.HasNewExperience | statusModel.IsNewLevel | statusModel.HasNewPrivilege;
            statusModel.Experience           = SettingsService.GetUserExperience(user);
            statusModel.Level         = SettingsService.GetUserLevel(user);
            statusModel.UserLevelInfo = AccomplishmentService.GetUserLevelInfo(user);

            var userSettings = new List <UserSettingModel>();

            foreach (var userSetting in user.UserSettings.OrderBy(us => us.CreatedOn))
            {
                if (userSetting.Name != UserSettingTypes.LevelSetting && userSetting.Name != UserSettingTypes.ExperienceSetting)
                {
                    userSettings.Add(new UserSettingModel()
                    {
                        Name      = userSetting.Name,
                        Value     = userSetting.Value,
                        CreatedOn = userSetting.CreatedOn
                    });
                }
            }
            statusModel.UserSettings = userSettings.ToArray();

            return(saveToDb);
        }
Пример #5
0
        //Invoke is de entrypoint. Van hieruit kunnen we bepalen welke View we willen instantiëren
        public IViewComponentResult Invoke()
        {
            UserStatusModel userStatus = SessionController.CheckLoggedInStatus(this.HttpContext);

            if (userStatus.LoggedIn == false)
            {
                return(View("NotLoggedIn"));
            }

            else
            {
                return(View("LoggedIn", userStatus));
            }
        }
Пример #6
0
        public IActionResult RemoveFromShoppingcart(int fld_offeredserviceid)
        {
            //Check if user is logged in
            UserStatusModel status = SessionController.CheckLoggedInStatus(this.HttpContext);

            if (status.LoggedIn == true)
            {
                //If user is logged in, remove the item from the database as well
                DatabaseController.RemoveFromShoppingCart(fld_offeredserviceid, status.userId);
            }
            string currentKey = "SC" + fld_offeredserviceid;

            Response.Cookies.Delete(currentKey);

            return(RedirectToAction("ShoppingCart", "ShoppingCart"));
        }
        public ResultModel <BussinessStatusModel> GetUserStatus(UserStatusModel parModel)
        {
            var model = iBusinessProvider.GetUserStatus(parModel.userId);

            if (model != null)
            {
                return(ResultModel <BussinessStatusModel> .Conclude(
                           UserStatus.Success,
                           model
                           ));
            }
            return(ResultModel <BussinessStatusModel> .Conclude(
                       UserStatus.Error,
                       null
                       ));
        }
        public ResultModel <ClienterStatusModel> GetUserStatus(UserStatusModel parModel)
        {
            var model = new ClienterProvider().GetUserStatus(parModel.userId);

            if (model != null)
            {
                return(ResultModel <ClienterStatusModel> .Conclude(
                           UserStatus.Success,
                           model
                           ));
            }
            return(ResultModel <ClienterStatusModel> .Conclude(
                       UserStatus.Error,
                       null
                       ));
        }
Пример #9
0
        public IActionResult Get()
        {
            var userFromAuth = UserService.GetUserFromClaims(this.User, UserRepo, RequestLogger);

            RequestLogger.UserId = userFromAuth.Id.ToString();

            var statusModel = new UserStatusModel()
            {
                IsEnabled    = userFromAuth.IsEnabled,
                AccountCount = AccountRepo.FindCountByOwner(userFromAuth.Id),
                BudgetCount  = BudgetRepo.FindCountByOwner(userFromAuth.Id),
            };

            if (statusModel.AccountCount == 0 || statusModel.BudgetCount == 0)
            {
                statusModel.IsNew = true;
            }
            return(Ok(statusModel));
        }
Пример #10
0
        public async Task <IActionResult> Create(UserStatusModel model)
        {
            var exist = _userStatusService.FindByName(model.Name);

            if (exist != null)
            {
                return(RedirectToErrorPage());
            }

            var status = new UserStatusModifyRequest()
            {
                Id          = model.Id,
                Name        = model.Name,
                Description = model.Description
            };

            var id = await _userStatusService.CreateAsync(status);

            return(RedirectToAction(nameof(Detail), new { id }));
        }
        public static UserStatusModel CheckLoggedInStatus(HttpContext context)
        {
            //Get the browser session from the accessor
            ISession session = context.Session;

            //Ready the value for the following bool returning function
            byte[] value = { };

            //check if value for loggedIn exists
            bool loggedIn = session.TryGetValue("LoggedIn", out value);

            //Ready the user status model
            UserStatusModel userStatusMdl = new UserStatusModel();

            userStatusMdl.LoggedIn = false;

            if (loggedIn)
            {
                //It exists, which means the user has logged in before, and we can use the session value
                string isUserLoggedIn = session.GetString("LoggedIn");
                if (isUserLoggedIn == "true")
                {
                    //User is currently logged in
                    userStatusMdl.EmailAddress = session.GetString("User");
                    userStatusMdl.Username     = session.GetString("UserName");
                    userStatusMdl.userId       = (int)session.GetInt32("UserId");
                    userStatusMdl.LoggedIn     = true;
                    userStatusMdl.adminPriv    = session.GetString("Admin");
                }
                else if (isUserLoggedIn == "false")
                {
                    //User has logged out at some point
                }
                return(userStatusMdl);
            }
            //User has never logged in before during this session
            return(userStatusMdl);
        }
Пример #12
0
        private IActionResult GetStatusInternal(bool acknowledgeAccomplishments)
        {
            var userFromAuth = UserService.GetUserFromClaims(this.User, UserRepo, RequestLogger);

            RequestLogger.UserId = userFromAuth.Id.ToString();

            var statusModel = new UserStatusModel()
            {
                IsEnabled    = userFromAuth.IsEnabled,
                AccountCount = AccountRepo.FindCountByOwner(userFromAuth.Id),
                BudgetCount  = BudgetRepo.FindCountByOwner(userFromAuth.Id),
            };

            if (statusModel.AccountCount == 0 || statusModel.BudgetCount == 0)
            {
                statusModel.IsNew = true;
            }
            if (AccomplishmentService.GetAccomplishmentsAndSettings(statusModel, userFromAuth, acknowledgeAccomplishments))
            {
                UserRepo.UpsertFromEditableModelStates(userFromAuth, userFromAuth.UserName);
            }
            return(Ok(statusModel));
        }
Пример #13
0
        public async Task <IActionResult> Update(UserStatusModel model)
        {
            if (model.Id <= 0)
            {
                return(RedirectToErrorPage());
            }

            var exist = _userStatusService.Find(model.Id);

            if (exist == null)
            {
                return(RedirectToErrorPage());
            }

            var status = new UserStatusModifyRequest()
            {
                Id          = model.Id,
                Name        = model.Name,
                Description = model.Description
            };
            await _userStatusService.UpdateAsync(status);

            return(RedirectToAction(nameof(Detail), new { id = status.Id }));
        }
Пример #14
0
 public ResultAdapter(UserStatusModel model)
 {
     _model = model;
 }
Пример #15
0
 public UserStatusContainer(UserStatusModel model, string userName)
 {
     RegisterOnlineChecker(model, userName);
 }
Пример #16
0
 public PageController()
 {
     this.serviceMdl    = new tbl_servicedata();
     this.userStatusMdl = new UserStatusModel();
 }
Пример #17
0
        public IActionResult Create()
        {
            var model = new UserStatusModel();

            return(View(model));
        }
        public async Task <UserStatusModel> SignUp(UserSignupModel model)
        {
            var exists = await _managerUser.FindByEmailAsync(model.Email);

            if (exists != null)
            {
                throw new MRException <UserStatusModel>((int)ExceptionCode.SYSTEM_EXCEPTION, "User with this email already exists");
            }

            var user       = _mapper.Map <User>(model);
            var saveResult = await _managerUser.CreateAsync(user);

            if (!saveResult.Succeeded)
            {
                throw new MRException <UserStatusModel>((int)ExceptionCode.SYSTEM_EXCEPTION, "Can not create user");
            }

            await _managerUser.AddPasswordAsync(user, model.Password);

            await _managerUser.AddToRoleAsync(user, AppRoles.USER.ToString());

            string providerToken = null;

            if (!string.IsNullOrWhiteSpace(model.ProviderSlug))
            {
                var provider = await _repositoryProvider.GetFirst(x => x.Slug == model.ProviderSlug && x.State == MREntityState.Active);

                if (provider != null)
                {
                    if (!provider.Options.IsRegistrationAvaliable)
                    {
                        throw new MRException <object>(-1, "Provider registration disabled");
                    }

                    providerToken = ProviderTokenGenerator.Generate(provider.Id, user.Id);
                }
            }

            var token = _serviceToken.GenerateToken(user.Id, user.Email, new List <string> {
                AppRoles.USER.ToString()
            });

            var response = new UserStatusModel
            {
                FirstName   = user.FirstName,
                LastName    = user.LastName,
                Email       = user.Email,
                AccessToken = token,
                Roles       = new List <string> {
                    AppRoles.USER.ToString()
                },
                LanguageCode     = user.LanguageCode,
                Sex              = user.Sex,
                CallbackUrl      = model.CallbackUrl,
                CallbackToken    = providerToken,
                IsEmailConfirmed = false,
                IsEmailOnChange  = false
            };

            return(response);
        }