예제 #1
0
 public List <VisitViewModel> Read(VisitBindingModel model)
 {
     if (model == null)
     {
         return(_visitStorage.GetFullList());
     }
     if (model.Id.HasValue)
     {
         return(new List <VisitViewModel> {
             _visitStorage.GetElement(model)
         });
     }
     return(_visitStorage.GetFilteredList(model));
 }
예제 #2
0
        public void Linking(DistributionLinkingBindingModel model)
        {
            var distribution = _distributionStorage.GetElement(new DistributionBindingModel
            {
                Id = model.DistributionId
            });

            var visit = _visitStorage.GetElement(new VisitBindingModel
            {
                Id = model.VisitId
            });

            if (distribution == null)
            {
                throw new Exception("Не найдена выдача");
            }

            if (visit == null)
            {
                throw new Exception("Не найдено посещение");
            }

            if (distribution.VisitId.HasValue)
            {
                throw new Exception("Данная выдача уже привязана к посещению");
            }

            _distributionStorage.Update(new DistributionBindingModel
            {
                Id                    = distribution.Id,
                IssueDate             = distribution.IssueDate,
                DistributionCosmetics = distribution.DistributionCosmetics,
                EmployeeId            = distribution.EmployeeId,
                VisitId               = model.VisitId
            });
        }