Ejemplo n.º 1
0
        public virtual ActionResult Index(string id, UserAwardViewModel model)
        {
            var ua = model.CreateAward(CurrentUser, CurrentResource);

            if (ua.Amount.HasValue)
            {
                TryAwardPointsTo(
                    Users[ua.Recipient],
                    ua.Amount.Value);
            }
            UserAwards.Save(ua);

            if (model.Email)
            {
                Messaging.SendAward(ControllerContext.RequestContext, ua);
                Notifier.Notify(
                    Severity.Success,
                    "Your award has been emailed!",
                    "The recipient should receive an email shortly with a link they can use to view or print their certificate.",
                    ua);
            }
            else
            {
                Notifier.Notify(
                    Severity.Success,
                    "Your award has been sent.",
                    "You indicated that you would print and deliver the certificate yourself, so we didn't email the recipient. Have fun delivering the good news!",
                    ua);
                TempData["popup-certificate"] = ua.Document.Id;
            }
            return(RedirectToAction(MVC.Site.Home.Index()));
        }
Ejemplo n.º 2
0
        public void CreateUserAwards(UserAwards ua)
        {
            if (ua == null)
            {
                throw new ArgumentNullException();
            }

            userawardsdao.CreateAwards(ua);
        }
Ejemplo n.º 3
0
        public bool CreateAwards(UserAwards ua)
        {
            if (ua == null)
            {
                throw new ArgumentNullException();
            }

            handler.CSVWriter(ua);
            return(true);
        }
Ejemplo n.º 4
0
        public bool CSVWriter(UserAwards aw)
        {
            if (aw == null)
            {
                throw new ArgumentNullException();
            }

            var writeMessage = $"{aw.Id = GetMaxId(AppConst.userAwardsPath) + 1 };{aw.UserId};{aw.AwardsId}" + Environment.NewLine;

            File.AppendAllText(AppConst.userAwardsPath, writeMessage
                               , Encoding.Default);
            ReWriteId(aw.Id, AppConst.userAwardsPath);
            return(true);
        }
Ejemplo n.º 5
0
        public virtual ActionResult Award(string id, UserAwardViewModel model)
        {
            var award = Awards[id];

            var ua = model.CreateAward(CurrentUser, award);

            if (ua.Amount.HasValue)
            {
                Accounting.CreateProgramAward(
                    award,
                    CurrentUser,
                    Users[ua.Recipient],
                    ua.Amount.Value,
                    award.Content.Title
                    );
            }
            UserAwards.Save(ua);
            Messaging.SendAward(ControllerContext.RequestContext, ua);

            return(Index());
        }
Ejemplo n.º 6
0
        private static void AddUserAwards()
        {
            var        users  = userlogic.GetAll;
            var        awards = awardslogic.GetAll;
            UserAwards ua     = new UserAwards();

            Console.WriteLine("\nUsers\n\n\n");
            PrintUsers(users);
            Console.WriteLine("Awards\n\n\n");
            PrintAwards(awards);
            Console.WriteLine("Write Username for gived awards");
            var name = Console.ReadLine();

            ua.UserId = users.Where(x => x.Name.Contains(name)).FirstOrDefault().Id;
            Console.WriteLine("Write awards title");
            var title = Console.ReadLine();

            ua.AwardsId = awards.Where(x => x.Title.Contains(title)).FirstOrDefault().Id;
            userawardslogic.CreateUserAwards(ua);
            Console.WriteLine("User awards add Successfull");
            Console.Clear();
            AddUserAwards();
        }