예제 #1
0
        // GET: FunAdmin/FContentChecks/Create
        public async Task <IActionResult> Create(Guid _ContentId)
        {
            var User_ = await _userManager.GetUserAsync(User);

            var _IsCurrentUserRoleInAdmin = await _userManager.IsInRoleAsync(User_, X_DOVEValues._administrator);

            var _FContentCheck = new FContentCheck
            {
                ContentId = _ContentId,
                IllegalityTypeSelectListItems = _funAdminHelper.GetIllegalityTypeSelectListItems(),
                IsLegal = false,
            };

            ViewData["IsCurrentUserRoleInAdmin"] = _IsCurrentUserRoleInAdmin;
            ViewData["IsReportSubmittedByUser"]  = !_IsCurrentUserRoleInAdmin;
            ViewData["IsEdit"] = false;

            return(View(_FContentCheck));
        }
예제 #2
0
        private string AppellantCommentForSubsequentCheck(FContentCheck fContentCheck, FContentCheck _FContentCheck)
        {
            return((_FContentCheck.IllegalityType == fContentCheck.IllegalityType && _FContentCheck.IllegalityType == "110") ?

                   _FContentCheck.AppellantComment :

                   (_funAdminHelper.GetIllegalityTypeSelectListItems()
                    .Where(p => p.Value == _FContentCheck.IllegalityType)
                    .Select(p => p.Text)
                    .FirstOrDefault() + "-->"

                    + (_FContentCheck.AppellantComment.Contains("-->") ?

                       _FContentCheck.AppellantComment.Substring(
                           _FContentCheck.AppellantComment.LastIndexOf("-->") + 3
                           ) :

                       _FContentCheck.AppellantComment
                       )
                   ));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("Id,ContentId,AppellantComment,ReceptionistComment,IsLegal,IllegalityType")] FContentCheck fContentCheck)
        {
            if (ModelState.IsValid)
            {
                var User_ = await _userManager.GetUserAsync(User);

                var _IsCurrentUserRoleInAdmin = await _userManager.IsInRoleAsync(User_, X_DOVEValues._administrator);

                fContentCheck.Id = Guid.NewGuid();

                if (_IsCurrentUserRoleInAdmin)
                {
                    fContentCheck.DOHandling     = DateTimeOffset.Now;
                    fContentCheck.ReceptionistId = User_.Id;
                }
                else
                {
                    fContentCheck.DOSubmitting = DateTimeOffset.Now;
                    fContentCheck.AppellantId  = User_.Id;
                    fContentCheck.IsLegal      = true;
                }

                if (
                    !_funAdminHelper.GetIllegalityTypeSelectListItems().Select(p => p.Value).Contains(fContentCheck.IllegalityType)
                    )
                {
                    fContentCheck.IllegalityType = "110";
                }

                _context.Add(fContentCheck);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(fContentCheck));
        }
예제 #4
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,AppellantId,ReceptionistId,AppellantComment,ReceptionistComment,IsLegal,IllegalityType")] FContentCheck fContentCheck)
        {
            if (id != fContentCheck.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var User_ = await _userManager.GetUserAsync(User);

                    var _IsCurrentUserRoleInAdmin = await _userManager.IsInRoleAsync(User_, X_DOVEValues._administrator);


                    var _FContentCheck = await _context.FContentCheck.FirstOrDefaultAsync(
                        p =>
                        p.Id == id
                        &&
                        (
                            _IsCurrentUserRoleInAdmin? true:
                            (p.AppellantId == User_.Id)
                        )
                        );

                    if (_FContentCheck == null)
                    {
                        return(NotFound());
                    }

                    var IsReportSubmittedByUser = !string.IsNullOrEmpty(_FContentCheck.AppellantId);

                    var IsChecked = !string.IsNullOrEmpty(_FContentCheck.ReceptionistId);


                    if (_IsCurrentUserRoleInAdmin)
                    {
                        _FContentCheck.ReceptionistComment = fContentCheck.ReceptionistComment;

                        if (IsReportSubmittedByUser && IsChecked)
                        {
                            _FContentCheck.AppellantComment = AppellantCommentForSubsequentCheck(fContentCheck, _FContentCheck);
                        }

                        _FContentCheck.DOHandling     = DateTimeOffset.Now;
                        _FContentCheck.ReceptionistId = User_.Id;
                        _FContentCheck.IsLegal        = fContentCheck.IsLegal;
                    }
                    else
                    {
                        _FContentCheck.AppellantComment = fContentCheck.AppellantComment;
                        _FContentCheck.DOSubmitting     = DateTimeOffset.Now;
                    }

                    _FContentCheck.IllegalityType =
                        (_IsCurrentUserRoleInAdmin && fContentCheck.IsLegal)?string.Empty:
                        _funAdminHelper.GetIllegalityTypeSelectListItems().Select(p => p.Value).Contains(fContentCheck.IllegalityType)?
                        fContentCheck.IllegalityType:"110";


                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FContentCheckExists(fContentCheck.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(fContentCheck));
        }