Exemple #1
0
        public IHttpActionResult UpdateCurrentDocElectronicServiceStage(
            int id,
            string docVersion,
            DocElectronicServiceStageDO docElectronicServiceStage)
        {
            using (var transaction = this.unitOfWork.BeginTransaction())
            {
                UnitUser unitUser = this.unitOfWork.DbContext.Set<UnitUser>().FirstOrDefault(e => e.UserId == this.userContext.UserId);

                int caseDocId = this.docRepository.GetCaseId(id);

                ClassificationPermission editTechElectronicServiceStagePermission = this.classificationRepository.GetByAlias("EditTechElectronicServiceStage");
                ClassificationPermission readPermission = this.classificationRepository.GetByAlias("Read");

                bool hasEditTechElectronicServiceStagePermission =
                    this.classificationRepository.HasPermission(unitUser.UnitId, caseDocId, editTechElectronicServiceStagePermission.ClassificationPermissionId) &&
                    this.classificationRepository.HasPermission(unitUser.UnitId, caseDocId, readPermission.ClassificationPermissionId);

                if (!hasEditTechElectronicServiceStagePermission)
                {
                    return BadRequest("Not enough permissions!");
                }

                Doc doc = this.docRepository.Find(caseDocId,
                    e => e.DocElectronicServiceStages);

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

                doc.EnsureForProperVersion(Helper.StringToVersion(docVersion));

                doc.UpdateCurrentDocElectronicServiceStage(
                    docElectronicServiceStage.ElectronicServiceStageId,
                    docElectronicServiceStage.StartingDate,
                    docElectronicServiceStage.ExpectedEndingDate,
                    docElectronicServiceStage.EndingDate,
                    this.userContext);

                this.unitOfWork.Save();

                transaction.Commit();

                return Ok();
            }
        }
Exemple #2
0
        public IHttpActionResult CreateDocElectronicServiceStage(
            int id,
            string docVersion,
            DocElectronicServiceStageDO docElectronicServiceStage)
        {
            using (var transaction = this.unitOfWork.BeginTransaction())
            {
                Doc doc = this.docRepository.Find(this.docRepository.GetCaseId(id),
                    e => e.DocCorrespondents.Select(d => d.Correspondent),
                    e => e.DocElectronicServiceStages);

                doc.EnsureForProperVersion(Helper.StringToVersion(docVersion));

                DocElectronicServiceStage dess = doc.CreateDocElectronicServiceStage(
                    docElectronicServiceStage.ElectronicServiceStageId,
                    docElectronicServiceStage.StartingDate,
                    docElectronicServiceStage.ExpectedEndingDate,
                    docElectronicServiceStage.EndingDate,
                    true,
                    this.userContext);

                this.unitOfWork.Save();

                Email email = this.emailRepository.CreateElectronicServiceStageChangeEmail(doc, dess, Request);

                this.unitOfWork.DbContext.Set<Email>().Add(email);

                this.unitOfWork.Save();

                transaction.Commit();

                return Ok();
            }
        }
Exemple #3
0
        public IHttpActionResult EndCurrentDocElectronicServiceStage(
            int id,
            string docVersion,
            DocElectronicServiceStageDO docElectronicServiceStage)
        {
            using (var transaction = this.unitOfWork.BeginTransaction())
            {
                Doc doc = this.docRepository.Find(this.docRepository.GetCaseId(id),
                    e => e.DocElectronicServiceStages);

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

                doc.EnsureForProperVersion(Helper.StringToVersion(docVersion));

                doc.EndCurrentDocElectronicServiceStage(docElectronicServiceStage.EndingDate.Value, this.userContext);

                this.unitOfWork.Save();

                transaction.Commit();

                return Ok();
            }
        }