Exemple #1
0
        public Assessment CreateAsDraft(Assessment entity)
        {
            return(WithTransaction(() =>
            {
                CommonHelper.ValidateArgumentNotNull(entity, nameof(entity));

                // populate audit fields
                PopulateAuditFields(entity, null, creating: true);

                // the submitter must be set to current user
                entity.Submitter = CurrentUser;
                entity.SubmitTime = null;
                entity.ApprovalStatus = ApprovalStatus.Draft;
                entity.Title = CreateAssessmentTitle(null, entity);
                // following fields should not be set
                ResetCreatedAssessmentFields(entity);

                // perform action
                Assessment result = AssessmentService.Create(entity);

                Helper.Audit(AuditService, null, result,
                             CommonHelper.GetFullActionName(ActionContext, includeController: false),
                             CurrentUser.Username, _propertiesToSkipAuditing);
                return result;
            }));
        }
Exemple #2
0
 private async Task AssessmentCreate()
 {
     for (int i = 1; i <= 20; i++)
     {
         for (int j = 1; j <= 100; j++)
         {
             await _assessmentService.Create(
                 _applicationContext.Users.FirstOrDefault(w => w.UserName == $"SomeUserName{i}").Id,
                 _applicationContext.Products.FirstOrDefault(w => w.Name == $"SomeProductName{j}").Id,
                 Convert.ToByte(Rnd(1, 6)));
         }
     }
 }
Exemple #3
0
        public Assessment Submit(Assessment entity)
        {
            return(WithTransaction(() =>
            {
                CommonHelper.ValidateArgumentNotNull(entity, nameof(entity));

                Assessment existing = null;
                if (entity.Id > 0)
                {
                    existing = AssessmentService.Get(entity.Id);
                    CheckCanSubmit(existing);
                }

                CheckPerformedSitesSum(entity);

                // populate audit fields
                PopulateAuditFields(entity, existing, existing == null);
                entity.Title = CreateAssessmentTitle(existing, entity);
                // the submitter must be set to current user
                entity.Submitter = CurrentUser;
                entity.SubmitTime = DateTime.Now;
                entity.ApprovalStatus = ApprovalStatus.AwaitingBUFunctionalApproval;

                // following fields should not be set
                ResetCreatedAssessmentFields(entity);

                Assessment result = entity.Id > 0
                    ? AssessmentService.Update(entity)
                    : AssessmentService.Create(entity);

                Helper.Audit(AuditService, existing, result,
                             CommonHelper.GetFullActionName(ActionContext, includeController: false),
                             CurrentUser.Username, _propertiesToSkipAuditing);

                return result;
            }));
        }
Exemple #4
0
        public async Task <IActionResult> Create([FromBody] AssessmentViewModel model)
        {
            await _assessmentService.Create(Request.Headers["UserId"], model.ProductId, Convert.ToByte(model.Value));

            return(Ok());
        }