Example #1
0
        public void ArrangeItem()
        {
            _repo  = new ClaimsRepository();
            _claim = new Claims(1, ClaimType.car, "car accident", 100, new DateTime(2018, 05, 01), new DateTime(2018, 05, 02));

            _repo.CreateClaim(_claim);
        }
        public async Task <IActionResult> SignIn([FromBody] AuthRequest authArgs)
        {
            /* Login validating */
            if (IsLoginValid(authArgs))
            {
                /* Getting all user claims */
                var claimsIdentity =
                    new ClaimsIdentity
                    (
                        ClaimsRepository.AllClaimsByUsername(authArgs.Email),
                        CookieAuthenticationDefaults.AuthenticationScheme
                    );

                /* Signing user and generating cookie */
                await HttpContext.SignInAsync
                (
                    CookieAuthenticationDefaults.AuthenticationScheme,
                    new ClaimsPrincipal(claimsIdentity)
                );


                return(Ok());
            }

            return(BadRequest(new
            {
                error = "Not authorized user. Please verify email and password."
            }));
        }
        public async Task <ActionResult> ListThreads(int projectid)
        {
            var project = await ProjectRepository.GetProjectAsync(projectid);

            if (project == null)
            {
                return(NotFound());
            }
            var isMaster = project.HasMasterAccess(CurrentUserIdOrDefault);
            IEnumerable <int>?groupIds;

            if (isMaster)
            {
                groupIds = null;
            }
            else
            {
                var claims = await ClaimsRepository.GetClaimsForPlayer(projectid, ClaimStatusSpec.Approved, CurrentUserId);

                groupIds = claims.SelectMany(claim => claim.Character.GetGroupsPartOf().Select(g => g.CharacterGroupId));
            }
            var threads = await ForumRepository.GetThreads(projectid, isMaster, groupIds);

            var viewModel = new ForumThreadListViewModel(project, threads, CurrentUserId);

            return(View(viewModel));
        }
        public void CreateNewClaim_AddToClaim_CountShouldBeTheSame()
        {
            ////AAA///
            ClaimsContent         claims     = new ClaimsContent();
            ClaimsRepository      _claimrepo = new ClaimsRepository();
            Queue <ClaimsContent> queue      = _claimrepo.SeeAllClaims();


            ///AA///
            ClaimsContent claim1 = new ClaimsContent(20, ClaimType.Home, "whole house burned down", 308987.34m, DateTime.Parse("03/01/2019"), DateTime.Parse("03/28/2019"));

            claim1.ClaimType = ClaimType.Home;
            ClaimType expected = ClaimType.Home;

            //A//

            Assert.AreEqual(expected, claim1.ClaimType);
            Assert.AreEqual(20, claim1.ClaimId);
            Assert.AreEqual("whole house burned down", claim1.Description);
            Assert.AreEqual(308987.34m, claim1.ClaimAmount);
            Assert.AreEqual(DateTime.Parse("03/01/2019"), claim1.DateOfIncident);
            Assert.AreEqual(DateTime.Parse("03/28/2019"), claim1.DateOfClaim);

            _claimrepo.AddToQueue(claim1);

            int expected1 = 1;
            int actual    = queue.Count;

            Assert.AreEqual(expected1, actual);
        }
        public async Task <ActionResult> ResponsibleDiscussing(int projectid, int responsibleMasterId, string export)
        {
            var claims = await ClaimsRepository.GetClaimsForMaster(projectid, responsibleMasterId,
                                                                   ClaimStatusSpec.Discussion);

            return(await ShowMasterClaimList(projectid, export, "Обсуждаемые заявки на мастере", "Index", claims));
        }
        public async Task <ActionResult> ResponsibleOnHold(int projectid, int responsiblemasterid, string export)
        {
            var claims = await ClaimsRepository.GetClaimsForMaster(projectid, responsiblemasterid,
                                                                   ClaimStatusSpec.OnHold);

            return(await ShowMasterClaimList(projectid, export, "Лист ожидания на мастере", "Index", claims));
        }
Example #7
0
        public void ReceivedCall_IsAddedToQueue()
        {
            ClaimsRepository handler = new ClaimsRepository();
            var receivedCall         = handler.ViewNextCall(_callsList);

            Assert.AreEqual(receivedCall.CallId, _testCall1.CallId);
        }
Example #8
0
        public async Task <ActionResult> Problems(int projectId, string export)
        {
            var claims = (await ClaimsRepository.GetClaims(projectId, ClaimStatusSpec.Any)).Where(c => c.GetProblems().Any(p => p.Severity >= ProblemSeverity.Warning)).ToList();

            return
                (await ShowMasterClaimList(projectId, export, "Проблемные заявки", "Index", claims));
        }
        public async Task AddComment(int projectId, int claimId, int?parentCommentId, bool isVisibleToPlayer, string commentText, FinanceOperationAction financeAction)
        {
            var claim = (await ClaimsRepository.GetClaim(projectId, claimId)).RequestAccess(CurrentUserId,
                                                                                            ExtraAccessReason.Player);

            SetDiscussed(claim, isVisibleToPlayer);

            var parentComment = claim.CommentDiscussion.Comments.SingleOrDefault(c => c.CommentId == parentCommentId);

            Func <UserSubscription, bool> predicate   = s => s.Comments;
            CommentExtraAction?           extraAction = null;

            if (financeAction != FinanceOperationAction.None)
            {
                extraAction = PerformFinanceOperation(financeAction, parentComment, claim);
                predicate   = s => s.Comments || s.MoneyOperation;
            }


            var email = await AddCommentWithEmail <AddCommentEmail>(commentText, claim, isVisibleToPlayer,
                                                                    predicate, parentComment, extraAction);

            await UnitOfWork.SaveChangesAsync();

            await EmailService.Email(email);
        }
Example #10
0
        public async Task <ActionResult> ListForGroupDirect(int projectId, int characterGroupId, string export)
        {
            ViewBag.CharacterGroupId = characterGroupId;
            var claims = await ClaimsRepository.GetClaimsForGroups(projectId, ClaimStatusSpec.Active, new [] { characterGroupId });

            return(await ShowMasterClaimList(projectId, export, "Заявки в группу (напрямую)", "ListForGroupDirect", claims));
        }
Example #11
0
        public async Task <ActionResult> ResponsibleProblems(int projectId, int responsibleMasterId, string export)
        {
            var claims = (await ClaimsRepository.GetActiveClaimsForMaster(projectId, responsibleMasterId, ClaimStatusSpec.Any)).Where(claim =>
                                                                                                                                      claim.GetProblems().Any(p => p.Severity >= ProblemSeverity.Warning)).ToList();

            return(await ShowMasterClaimList(projectId, export, "Проблемные заявки на мастере", "Index", claims));
        }
        // GET api/<controller>/5
        public IHttpActionResult Get(string fileName)
        {
            try
            {
                claimsRepository = new ClaimsRepository();

                if (string.IsNullOrEmpty(fileName))
                {
                    return(BadRequest());
                }

                var xmlData = claimsRepository.GetXmlData(fileName);

                if (string.IsNullOrEmpty(xmlData))
                {
                    return(NotFound());
                }

                return(Ok(xmlData));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Example #13
0
        public async Task DeclineByPlayer(int projectId, int claimId, string commentText)
        {
            var claim = await ClaimsRepository.GetClaim(projectId, claimId);

            if (claim == null)
            {
                throw new DbEntityValidationException();
            }
            claim.RequestPlayerAccess(CurrentUserId);
            claim.EnsureCanChangeStatus(Claim.Status.DeclinedByUser);

            claim.PlayerDeclinedDate = Now;
            MarkCharacterChangedIfApproved(claim);
            claim.ClaimStatus = Claim.Status.DeclinedByUser;

            if (claim.Character == null)
            {
                throw new InvalidOperationException("Unexpected");
            }

            claim.Character.ApprovedClaimId = null;

            var email =
                await
                AddCommentWithEmail <DeclineByPlayerEmail>(commentText, claim, true,
                                                           s => s.ClaimStatusChange, null, CommentExtraAction.DeclineByPlayer);

            await UnitOfWork.SaveChangesAsync();

            await EmailService.Email(email);
        }
Example #14
0
        public void Arrange()
        {
            _repo  = new ClaimsRepository();
            _claim = new Claims(1, ClaimType.Home, "Home fire", 4000, DateTime.Parse("06/11/2020"), DateTime.Parse("06/12/2020"));

            _repo.AddClaimToQueue(_claim);
        }
Example #15
0
        public async Task <ClaimCheckInValidationResult> PrepareClaimFoCheckIn([FromUri]
                                                                               int projectId,
                                                                               [FromUri]
                                                                               int claimId)
        {
            var claim = await ClaimsRepository.GetClaim(projectId, claimId);

            if (claim == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var validator = new ClaimCheckInValidator(claim);

            return
                (new ClaimCheckInValidationResult
            {
                ClaimId = claim.ClaimId,
                CheckedIn = !validator.NotCheckedInAlready,
                Approved = validator.IsApproved,
                CheckInPossible = validator.CanCheckInInPrinciple,
                EverythingFilled = !validator.NotFilledFields.Any(),
                ClaimFeeBalance = validator.FeeDue,
                Handouts = new[]     //TODO FIX ME
                {
                    new HandoutItem {
                        Label = "Хайратник"
                    },
                    new HandoutItem {
                        Label = "Ленточка"
                    },
                },
            });
        }
        public async Task <int> CreateThread(int projectId, int characterGroupId, string header, string commentText, bool hideFromUser, bool emailEverybody)
        {
            var group = await LoadProjectSubEntityAsync <CharacterGroup>(projectId, characterGroupId);

            group.RequestMasterAccess(CurrentUserId);
            var forumThread = new ForumThread()

            {
                CharacterGroupId  = characterGroupId,
                ProjectId         = projectId,
                Header            = Required(header),
                CreatedAt         = Now,
                ModifiedAt        = Now,
                AuthorUserId      = CurrentUserId,
                IsVisibleToPlayer = !hideFromUser,
                CommentDiscussion = new CommentDiscussion()
                {
                    ProjectId = projectId
                }
            };

            forumThread.CommentDiscussion.Comments.Add(new Comment()
            {
                CommentId         = -1,
                ProjectId         = projectId,
                AuthorUserId      = CurrentUserId,
                IsVisibleToPlayer = !hideFromUser,
                CommentText       = new CommentText()
                {
                    CommentId = -1,
                    Text      = new MarkdownString(commentText)
                },
                CreatedAt = Now,
            });

            group.ForumThreads.Add(forumThread);
            await UnitOfWork.SaveChangesAsync();

            if (emailEverybody)
            {
                var groups  = GetChildrenGroupIds(group);
                var players = hideFromUser ? new User[] {} :
                (await ClaimsRepository.GetClaimsForGroups(projectId, ClaimStatusSpec.Approved, groups)).Select(
                    claim => claim.Player);
                var masters = forumThread.Project.ProjectAcls.Select(acl => acl.User);

                var fe = new ForumEmail()
                {
                    ForumThread = forumThread,
                    ProjectName = forumThread.Project.ProjectName,
                    Initiator   = await UserRepository.GetById(CurrentUserId),
                    Recipients  = players.Union(masters).ToList(),
                    Text        = new MarkdownString(commentText),
                };

                await EmailService.Email(fe);
            }
            return(forumThread.ForumThreadId);
        }
Example #17
0
 public void Arrange()
 {
     _repo   = new ClaimsRepository();
     _claim  = new Claim(2, ClaimType.Vehicle, "Crashed motorcycle after high speed chase.", 1400.63, new DateTime(2020, 09, 15), new DateTime(2020, 10, 15));
     _claim2 = new Claim(3, ClaimType.Theft, "Home invasion and robbery. Gaming consoles and computers stolen.", 3500, new DateTime(2020, 09, 15), new DateTime(2020, 10, 15));
     _repo.AddNewClaim(_claim);
     _repo.AddNewClaim(_claim2);
 }
Example #18
0
        public void AddContentToQueue_ShouldGetCorrectBool()
        {
            Claims           content   = new Claims();
            ClaimsRepository repo      = new ClaimsRepository();
            bool             addResult = repo.AddContentToQueue(content);

            Assert.IsTrue(addResult);
        }
        public void Test_Add()
        {
            ClaimsRepository mr = new ClaimsRepository();
            Claim            c1 = new Claim(1, "Car", "Car accident on 465", 400, new DateTime(2021, 1, 3), new DateTime(2021, 1, 5), true);

            mr.Add(c1);
            Assert.IsTrue(mr.ClaimList.Count == 1);
        }
Example #20
0
        private async Task <Claim> LoadClaimForApprovalDecline(int projectId, int claimId, int currentUserId)
        {
            var claim = await ClaimsRepository.GetClaim(projectId, claimId);

            return(claim.RequestAccess(currentUserId,
                                       acl => acl.CanManageClaims,
                                       ExtraAccessReason.ResponsibleMaster));
        }
Example #21
0
        public void UpdateExistingMenu_ShouldReturnTrue()
        {
            Claim            content       = new Claim();
            ClaimsRepository repository    = new ClaimsRepository();
            bool             updateResults = repository.GetNextClaim();

            Assert.IsTrue(updateResults);
        }
Example #22
0
        public void ClaimWithinTimeframe_IsValid()
        {
            List <Claim> claims = _claimRepo.GetClaimsList();
            Claim        claim  = claims[0];

            ClaimsRepository handler = new ClaimsRepository();

            Assert.IsTrue(handler.IsValidEntryDate(claim));
        }
Example #23
0
        public void ClaimOutsideOfTimeframe_IsNotValid()
        {
            List <Claim> claims = _claimRepo.GetClaimsList();
            Claim        claim  = claims[1];

            ClaimsRepository handler = new ClaimsRepository();

            Assert.IsFalse(handler.IsValidEntryDate(claim));
        }
Example #24
0
        public void ClaimUnderTenThousand_IsValid()
        {
            List <Claim> claims = _claimRepo.GetClaimsList();
            Claim        claim  = claims[0];

            ClaimsRepository handler = new ClaimsRepository();

            Assert.AreEqual("Your claim is being processed.", handler.ValidateAmount(claim));
        }
Example #25
0
        public void ClaimOverTenThousand_IsNotValid()
        {
            List <Claim> claims = _claimRepo.GetClaimsList();
            Claim        claim  = claims[2];

            ClaimsRepository handler = new ClaimsRepository();

            Assert.AreEqual("Please call your agent, now.", handler.ValidateAmount(claim));
        }
Example #26
0
        public void CreateClaim_GetBoolean()
        {
            Claims           claims = new Claims();
            ClaimsRepository repo   = new ClaimsRepository();

            bool wasAddedCorrectly = repo.CreateClaim(claims);

            Assert.IsTrue(wasAddedCorrectly);
        }
        public async Task <ActionResult> PaidDeclined(int projectid, string export)
        {
            var claims =
                (await ClaimsRepository.GetClaims(projectid, ClaimStatusSpec.InActive))
                .Where(claim => claim.ClaimBalance() > 0)
                .ToList();

            return(await ShowMasterClaimList(projectid, export, "Оплаченные отклоненные заявки", "Index", claims));
        }
Example #28
0
 public async Task SubscribeClaimToUser(int projectId, int claimId)
 {
     var user = await UserRepository.GetWithSubscribe(CurrentUserId);
     _ = (await ClaimsRepository.GetClaim(projectId, claimId)).RequestAccess(CurrentUserId);
     _ = user.Subscriptions.Add(
         new UserSubscription() { ClaimId = claimId, ProjectId = projectId }.AssignFrom(
             SubscribeOptionsExtensions.AllSet()));
     await UnitOfWork.SaveChangesAsync();
 }
        public async Task <ActionResult> WaitingForFee(int projectid, string export)
        {
            var claims =
                (await ClaimsRepository.GetClaims(projectid, ClaimStatusSpec.Approved))
                .Where(claim => !claim.ClaimPaidInFull())
                .ToList();

            return(await ShowMasterClaimList(projectid, export, "Неоплаченные принятые заявки", "Index", claims));
        }
        public async Task <ActionResult> Responsible(int projectid, int responsibleMasterId, string export)
        {
            var claims =
                (await ClaimsRepository.GetClaimsForMaster(projectid, responsibleMasterId, ClaimStatusSpec.Active))
                .ToList
                    ();

            return(await ShowMasterClaimList(projectid, export, "Заявки на мастере", "Index", claims));
        }