Ejemplo n.º 1
0
        public async Task GetAccountInfoByUserName()
        {
            var accountInfoEdit = await AccountInfoEdit.GetAccountInfoForEmployee(Constants.KevinFUserId);

            Assert.IsNotNull(accountInfoEdit);
            Assert.AreEqual(Constants.KevinFUserName, accountInfoEdit.UserName);
        }
        public async virtual Task <ActionResult> SubmitPayout(int pointPayoutThreshold)
        {
            var accountInfo = await AccountInfoEdit.GetAccountInfoForEmployee(AuthenticatedUser.EmployeeId);

            accountInfo.PointPayoutThreshold = pointPayoutThreshold;
            if (!await SaveObjectAsync(accountInfo, true))
            {
                return(new HttpStatusCodeResult(500, ApplicationResources.InvalidPayoutThreshold));
            }

            return(PartialView(Mvc.Account.Views.ViewNames.PayoutThreshold, accountInfo));
        }
        public async virtual Task <ActionResult> Index()
        {
            var accountInfo = await AccountInfoEdit.GetAccountInfoForEmployee(AuthenticatedUser.EmployeeId);

            var badgeHistory = await EarnedBadgeCollection.GetAllBadgesForUserByTypeAsync(AuthenticatedUser.EmployeeId, BadgeType.Unset);

            var accountInfoIndexViewModel = new AccountInfoIndexViewModel(badgeHistory)
            {
                AccountInfo = accountInfo,
            };

            return(View(accountInfoIndexViewModel));
        }
Ejemplo n.º 4
0
        public ActionResult EditAccountInfo (int id)
        {
            var service = CreateAccountInfoService();
            var detail = service.GetAccountInfoByAccountID(id);
            var model = new AccountInfoEdit
            {
                AccountID = detail.AccountID,
                FirstName = detail.FirstName,
                LastName = detail.LastName,
                State = detail.State,
                Country = detail.Country
            };

            return View(model);

        }
Ejemplo n.º 5
0
        public async Task UpdateBadge()
        {
            var newValue    = 200;
            var accountInfo = await AccountInfoEdit.GetAccountInfoForEmployee(Constants.KevinFUserId);

            var oldValue = accountInfo.PointPayoutThreshold;

            accountInfo.PointPayoutThreshold = newValue;

            accountInfo = (IAccountInfoEdit)accountInfo.Save();

            Assert.AreEqual(newValue, accountInfo.PointPayoutThreshold);

            //reset
            accountInfo.PointPayoutThreshold = oldValue;
            accountInfo.Save();
        }
Ejemplo n.º 6
0
        public string NewUploadedFile(AccountInfoEdit model) // creates the unique URL and loads the image into the file folder
        {
            string uniqueFileName = "";

            if (model.PictureImage != null)
            {
                string uploadsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content/Images");

                uniqueFileName = Guid.NewGuid().ToString() + "-" + model.PictureImage.FileName;

                string filePath = Path.Combine(uploadsFolder, uniqueFileName);

                model.PictureImage.SaveAs(filePath);
            }
            else if (model.PictureImage == null)
            {
                return(uniqueFileName = "default-avatar-image.jpg");
            }

            return(uniqueFileName);
        }
Ejemplo n.º 7
0
        public bool UpdateAccountInfo(AccountInfoEdit model)
        {
            string uniqueFileName = NewUploadedFile(model);

            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx
                             .Accounts
                             .Single(e => e.UserID == _userID && e.AccountID == model.AccountID);

                entity.AccountID   = model.AccountID;
                entity.FirstName   = model.FirstName;
                entity.LastName    = model.LastName;
                entity.State       = model.State;
                entity.Country     = model.Country;
                entity.PictureURL  = uniqueFileName;
                entity.ModifiedUTC = DateTimeOffset.Now;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 8
0
        public ActionResult EditAccountInfo(int id, AccountInfoEdit model)
        {

            var service = CreateAccountInfoService();

            var validImageTypes = new string[]
                 {
                    "image/gif",
                    "image/jpeg",
                    "image/png"
                 };

            if (model.PictureImage != null && !validImageTypes.Contains(model.PictureImage.ContentType))
            {
                ModelState.AddModelError("ImageUpload", "Please choose either a GIF, JPG or PNG image.");
            }
           
            if (!ModelState.IsValid) return View(model);

             if(model.AccountID != id) // not sure this is needed
              {
                 ModelState.AddModelError("", "Id Mismatch");
                 return View(model);
              }


            if (service.UpdateAccountInfo(model))
            {
                TempData["Save Result"] = "Your account information was updated.";
                return RedirectToAction("Index");
            }

            ModelState.AddModelError("", "Your accounnt information could not be updated.");
            return View(model);


        }