コード例 #1
0
        public bool RegisterApplication(AppShortDTO model)
        {
            _entityStateHelper.CheckChangeAppStatus(model.Id, "Registered");
            var prlApplication = _dataService.GetEntity <PrlApplication>(app => app.Id == model.Id).Single();

            //if (prlApplication.RegNumber == model.RegNumber)
            //{
            //    return false;
            //}
            _objectMapper.Map(model, prlApplication);
            _dataService.SaveChanges();
            var appDetailDto = _dataService.GetDto <PrlAppDetailDTO>(application => application.Id == prlApplication.Id).Single();

            var DublicateRegNum = _dataService.GetDto <PrlAppDetailDTO>(x =>
                                                                        x.RegNumber == appDetailDto.RegNumber && x.RegDate == appDetailDto.RegDate).ToList();

            if (DublicateRegNum.Count <= 1)
            {
                var backOfficeState = prlApplication.BackOfficeAppState;
                var appState        = prlApplication.AppState;

                prlApplication.BackOfficeAppState = "Registered";
                prlApplication.AppState           = "InReview";
                _dataService.SaveChanges();

                try
                {
                    if (prlApplication.AppSort != "AdditionalInfoToLicense")
                    {
                        _limsExchangeService.InsertApplication(prlApplication);
                    }
                }
                catch (Exception e)
                {
                    prlApplication.BackOfficeAppState = backOfficeState;
                    prlApplication.AppState           = appState;
                    prlApplication.RegDate            = null;
                    prlApplication.RegNumber          = null;
                    _dataService.SaveChanges();
                    throw new Exception("Виникла помилка при регестрації заяви. Зверніться до адміністратора", e);
                }

                return(true);
            }
            else
            {
                //_dataService.Remove(prlApplication);
                return(false);
            }
        }