コード例 #1
0
        public IActionResult Add(int CaseSessionActId)
        {
            var sessionAct = service.GetById <CaseSessionAct>(CaseSessionActId);

            SetViewbagCaption(CaseSessionActId);
            var model = new CaseSessionActCoordination()
            {
                CaseId           = sessionAct.CaseId,
                CourtId          = sessionAct.CourtId,
                CaseSessionActId = CaseSessionActId,
            };

            return(View(nameof(Edit), model));
        }
コード例 #2
0
        /// <summary>
        /// Запис на Съгласуване на актове
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool CaseSessionActCoordination_SaveData(CaseSessionActCoordination model)
        {
            try
            {
                if (model.Id > 0)
                {
                    //Update
                    var saved = repo.GetById <CaseSessionActCoordination>(model.Id);
                    saved.Content = model.Content;
                    saved.ActCoordinationTypeId = model.ActCoordinationTypeId;
                    saved.DateWrt = DateTime.Now;
                    saved.UserId  = userContext.UserId;

                    repo.Update(saved);

                    var coordinationTasks = repo.AllReadonly <WorkTask>()
                                            .Where(x => x.SourceType == SourceTypeSelectVM.CaseSessionAct && x.SourceId == model.CaseSessionActId)
                                            .Where(x => x.TaskTypeId == WorkTaskConstants.Types.CaseSessionAct_Coordinate)
                                            .Where(x => WorkTaskConstants.States.NotFinished.Contains(x.TaskStateId))
                                            .Where(x => x.UserId == userContext.UserId)
                                            .ToList();
                    foreach (var _task in coordinationTasks)
                    {
                        _task.TaskStateId   = WorkTaskConstants.States.Completed;
                        _task.DateCompleted = DateTime.Now;
                        repo.Update(_task);
                    }
                    repo.SaveChanges();
                    return(true);
                }
                else
                {
                    model.DateWrt = DateTime.Now;
                    model.UserId  = userContext.UserId;
                    repo.Add <CaseSessionActCoordination>(model);
                    repo.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Грешка при запис на съгласуване Id={ model.Id }");
            }
            return(false);
        }
コード例 #3
0
        public IActionResult Edit(CaseSessionActCoordination model)
        {
            SetViewbagCaption(model.CaseSessionActId);
            if (!ModelState.IsValid)
            {
                return(View(nameof(Edit), model));
            }

            var currentId = model.Id;

            if (service.CaseSessionActCoordination_SaveData(model))
            {
                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));
        }