Exemple #1
0
        public IActionResult Edit(CaseSessionFastDocument model)
        {
            SetViewbag(model.CaseSessionId);
            if (!ModelState.IsValid)
            {
                return(View(nameof(Edit), model));
            }

            string _isvalid = IsValid(model);

            if (_isvalid != string.Empty)
            {
                SetErrorMessage(_isvalid);
                return(View(nameof(Edit), model));
            }

            var currentId = model.Id;

            if (service.CaseSessionFastDocument_SaveData(model))
            {
                SetAuditContext(service, SourceTypeSelectVM.CaseSessionFastDocument, model.Id, currentId == 0);
                this.SaveLogOperation(currentId == 0, model.Id);
                SetSuccessMessage(MessageConstant.Values.SaveOK);
                return(RedirectToAction(nameof(Edit), new { id = model.Id }));
            }
            else
            {
                SetErrorMessage(MessageConstant.Values.SaveFailed);
            }
            return(View(nameof(Edit), model));
        }
        /// <summary>
        /// Запис на Съпровождащ документ представен в заседание
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool CaseSessionFastDocument_SaveData(CaseSessionFastDocument model)
        {
            try
            {
                if (model.Id > 0)
                {
                    //Update
                    var saved = repo.GetById <CaseSessionFastDocument>(model.Id);
                    saved.CasePersonId      = model.CasePersonId;
                    saved.SessionDocTypeId  = model.SessionDocTypeId;
                    saved.SessionDocStateId = model.SessionDocStateId;
                    saved.Description       = model.Description;
                    saved.DateWrt           = DateTime.Now;
                    saved.UserId            = userContext.UserId;

                    repo.Update(saved);
                    repo.SaveChanges();
                }
                else
                {
                    //Insert
                    model.DateWrt = DateTime.Now;
                    model.UserId  = userContext.UserId;
                    repo.Add <CaseSessionFastDocument>(model);
                    repo.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Грешка при запис на Съпровождащ документ представен в заседание Id={ model.Id }");
                return(false);
            }
        }
Exemple #3
0
        /// <summary>
        /// Добавяне на Съпровождащ документ представен в заседание
        /// </summary>
        /// <param name="caseSessionId"></param>
        /// <returns></returns>
        public IActionResult Add(int caseSessionId)
        {
            if (!CheckAccess(service, SourceTypeSelectVM.CaseSessionFastDocument, null, AuditConstants.Operations.Append, caseSessionId))
            {
                return(Redirect_Denied());
            }
            var modelSession = service.GetById <CaseSession>(caseSessionId);
            var model        = new CaseSessionFastDocument()
            {
                CourtId       = modelSession.CourtId ?? 0,
                CaseId        = modelSession.CaseId,
                CaseSessionId = caseSessionId,
            };

            SetViewbag(caseSessionId);
            return(View(nameof(Edit), model));
        }
Exemple #4
0
        /// <summary>
        /// Валидация преди запис на Съпровождащ документ представен в заседание
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private string IsValid(CaseSessionFastDocument model)
        {
            if (model.CasePersonId < 1)
            {
                return("Изберете свързано лице");
            }

            if (model.SessionDocTypeId < 1)
            {
                return("Изберете вид документ");
            }

            if (model.SessionDocStateId < 1)
            {
                return("Изберете статус");
            }

            return(string.Empty);
        }
        /// <summary>
        /// Запис на Съпровождащ документ представен в заседание от чеклист
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool CaseSessionFastDocument_SaveSelectForSessionCheck(CheckListViewVM model)
        {
            try
            {
                var caseSession      = repo.GetById <CaseSession>(model.ObjectId);
                var caseSessionFasts = CaseSessionFastDocument_SelectForCopy(model.CourtId);
                var casePersonLists  = casePersonService.CasePerson_Select(caseSession.CaseId, caseSession.Id, true, false, false);

                foreach (var fastDocument in model.checkListVMs.Where(x => x.Checked))
                {
                    var sessionFastDocument = caseSessionFasts.Where(x => x.Id == int.Parse(fastDocument.Value)).FirstOrDefault();
                    var person = casePersonLists.Where(x => x.Uic == sessionFastDocument.CasePerson.Uic).FirstOrDefault();

                    if ((sessionFastDocument != null) && (person != null))
                    {
                        var caseSessionFastDocumentSave = new CaseSessionFastDocument()
                        {
                            CourtId                       = caseSession.CourtId ?? 0,
                            CaseId                        = caseSession.CaseId,
                            CaseSessionId                 = caseSession.Id,
                            CasePersonId                  = person.Id,
                            SessionDocTypeId              = sessionFastDocument.SessionDocTypeId,
                            Description                   = sessionFastDocument.Description,
                            SessionDocStateId             = sessionFastDocument.SessionDocStateId,
                            CaseSessionFastDocumentInitId = ((sessionFastDocument.CaseSessionFastDocumentInitId != null) ? sessionFastDocument.CaseSessionFastDocumentInitId : sessionFastDocument.Id),
                            DateWrt                       = DateTime.Now,
                            UserId                        = userContext.UserId
                        };

                        repo.Add <CaseSessionFastDocument>(caseSessionFastDocumentSave);
                    }
                }

                repo.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Грешка при копиране на Съпровождащ документ представен в заседание от заседание Id={ model.CourtId } в заседание Id={model.ObjectId}");
                return(false);
            }
        }