コード例 #1
0
        public Task <OperationDetails> AddAgreementAsync(AgreementDto AgreementDto)
        {
            throw new System.NotImplementedException();
            //if (customerDto == null)
            //{
            //    Logger.Error("Something went wrong");
            //    return new OperationDetails(false, "Something went wrong", "Customer");
            //}

            //Customer customer = mapper.Map<CustomerDto, Customer>(customerDto);
            //customer.User = await unitOfWork.UserManager.FindByIdAsync(customerDto.UserId);

            //try
            //{
            //    if (unitOfWork.CustomerRepository.GetByINN(customerDto.INN) != null)
            //    {
            //        Logger.Error("A Customer with this name already exists");
            //        return new OperationDetails(false, "Контрагент с таким ИНН уже существует", "Контрагенты");
            //    }
            //    await unitOfWork.CustomerRepository.CreateAsync(customer);
            //    await unitOfWork.SaveAsync();
            //    Logger.Info("Successfully added");
            //    return new OperationDetails(true);
            //}
            //catch (Exception ex)
            //{
            //    Logger.Error(ex.Message);
            //    return new OperationDetails(false, "Unfortunately, something went wrong....", "Контрагенты");
            //}
        }
コード例 #2
0
        public Task <OperationDetails> DeleteAgreementAsync(AgreementDto AgreementDto)
        {
            throw new System.NotImplementedException();

            //if (customerDto == null)
            //{
            //    Logger.Error("Customer is null");
            //    return new OperationDetails(false, "Something went wrong", "Контрагенты");
            //}

            //Customer customer = await unitOfWork.CustomerRepository.GetByIdAsync(customerDto.Id);
            //if (customer == null)
            //{
            //    Logger.Error("Контрагент не найден");
            //    return new OperationDetails(false, "Контрагент не найден", "Контрагенты");
            //}

            //try
            //{
            //    await unitOfWork.CustomerRepository.DeleteAsync(customer);
            //    await unitOfWork.SaveAsync();
            //    Logger.Info("Successfully deleted");
            //    return new OperationDetails(true);
            //}
            //catch (Exception ex)
            //{
            //    Logger.Error(ex.Message);
            //    return new OperationDetails(false, ex.Message);
            //}
        }
コード例 #3
0
        public Task <OperationDetails> UpdateAgreementAsync(AgreementDto AgreementDto)
        {
            throw new System.NotImplementedException();

            //if (customerDto == null)
            //{
            //    Logger.Error("Customer is null");
            //    return new OperationDetails(false, "Something went wrong", "Контрагенты");
            //}

            //Customer customer = mapper.Map<CustomerDto, Customer>(customerDto);
            //customer.User = await unitOfWork.UserManager.FindByIdAsync(customerDto.UserId);

            //try
            //{
            //    await unitOfWork.CustomerRepository.UpdateAsync(customer);
            //    await unitOfWork.SaveAsync();
            //    Logger.Info("Successfully updated");
            //    return new OperationDetails(true);
            //}
            //catch (Exception ex)
            //{
            //    Logger.Error(ex.Message);
            //    return new OperationDetails(false, ex.Message);
            //}
        }
コード例 #4
0
        public async Task <IActionResult> AddAgreement([FromBody] AgreementDto agreement)
        {
            var command = new AddAgreementCommand(agreement);
            var result  = await _mediator.Send(command);

            return(Ok(result));
        }
コード例 #5
0
 public static Agreement DtoToEntity(this AgreementDto agreementDto)
 {
     return(new Agreement()
     {
         DiscountAmount = agreementDto.DiscountAmount,
         DiscountPercentage = agreementDto.DiscountPercentage
     });
 }
コード例 #6
0
 public bool Delete(AgreementDto agreementDto)
 {            
     if(agreementDto != null)
     {
         _context.Agreement.Remove(agreementDto.DtoToEntity());
         _context.SaveChanges();
         return true;
     }
     return false;
 }
コード例 #7
0
        private void btsave_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tbclient.Text))
            {
                MessageBox.Show("Код организации не указан ୧((#Φ益Φ#))୨", "Фатальная ошибка");
                return;
            }
            if (string.IsNullOrEmpty(tbroom.Text))
            {
                MessageBox.Show("Номер помещения не указан ୧((#Φ益Φ#))୨", "Фатальная ошибка");
                return;
            }
            if (string.IsNullOrEmpty(tbstart.Text))
            {
                MessageBox.Show("Дата начала действия договора не указана ୧((#Φ益Φ#))୨", "Фатальная ошибка");
                return;
            }
            if (string.IsNullOrEmpty(tbfinish.Text))
            {
                MessageBox.Show("Дата окончания действия договора не указана ୧((#Φ益Φ#))୨", "Фатальная ошибка");
                return;
            }
            if (string.IsNullOrEmpty(tbday.Text))
            {
                MessageBox.Show("День ежемесячных выплат не указан ୧((#Φ益Φ#))୨", "Фатальная ошибка");
                return;
            }

            if (agreementdto == null)
            {
                AgreementDto agreementdto = new AgreementDto();
                agreementdto.ClientID = Convert.ToInt32(tbclient.Text);
                agreementdto.RoomID   = Convert.ToInt32(tbroom.Text);
                agreementdto.Start    = Convert.ToDateTime(tbstart.Text);
                agreementdto.Finish   = Convert.ToDateTime(tbfinish.Text);
                agreementdto.Payday   = Convert.ToDecimal(tbday.Text);

                IAgreementProcess agreementProcess = ProcessFactory.GetAgreementProcess();
                agreementProcess.Add(agreementdto);
                MessageBox.Show("Договор добавлен °˖✧◝(⁰▿⁰)◜✧˖° ", "Всё получилось!");
            }
            else
            {
                agreementdto.ClientID = Convert.ToInt32(tbclient.Text);
                agreementdto.RoomID   = Convert.ToInt32(tbroom.Text);
                agreementdto.Start    = Convert.ToDateTime(tbstart.Text);
                agreementdto.Finish   = Convert.ToDateTime(tbfinish.Text);
                agreementdto.Payday   = Convert.ToDecimal(tbday.Text);

                IAgreementProcess agreementProcess = ProcessFactory.GetAgreementProcess();
                agreementProcess.Update(agreementdto);
                MessageBox.Show("Данные изменены °˖✧◝(⁰▿⁰)◜✧˖° ", "Всё получилось!");
            }
        }
コード例 #8
0
 public IActionResult Update([FromBody] AgreementDto agreement)
 {
     if (_agreementAppService.Update(agreement))
     {
         return(Ok());
     }
     else
     {
         return(BadRequest());
     }
 }
コード例 #9
0
 public IActionResult Create([FromBody] AgreementDto agremmentDto)
 {
     if (_agremmentAppService.Create(agremmentDto))
     {
         return(Ok(agremmentDto));
     }
     else
     {
         return(BadRequest());
     }
 }
コード例 #10
0
 public bool Update(AgreementDto agreementDto)
 {
     try
     {
         _context.Agreement.Update(agreementDto.DtoToEntity());
         _context.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
コード例 #11
0
        private void btupdag_Click(object sender, RoutedEventArgs e)
        {
            AgreementDto item = dataGridAgreement.SelectedItem as AgreementDto;

            if (item == null)
            {
                MessageBox.Show("Ничего не было выбрано для изменения ╮( ̄ω ̄)╭ ", "Какой коwмар!");
                return;
            }

            AddAgreement wnd = new AddAgreement(item);

            wnd.ShowDialog();
            UpdateWND();
        }
コード例 #12
0
ファイル: RentService.cs プロジェクト: IIINickoIII/CarRental
        public int AddAgreement(AgreementDto agreementDto)
        {
            var agreement = Mapper.Map <Agreement>(agreementDto);

            Database.Agreements.Add(agreement);
            Database.Save();

            var carInDb = Database.Cars.Get(agreement.CarId.Value);

            carInDb.IsAvailable = false;

            Database.Cars.Update(carInDb);
            Database.Save();

            return(agreement.Id);
        }
コード例 #13
0
 public void AgreementUpdate(AgreementDto dto)
 {
     try
     {
         using (var db = new ONRRDatabaseEntities())
         {
             db.AgreementsUpdate(dto.AgreementID, dto.ONRRAgreementID, dto.BLMSerialNumber, dto.ONRRAgreementDescription,
                                 dto.Formation, dto.AgreementClassificationID, dto.AgreementTypeID, dto.TotalAcreage,
                                 dto.EffectiveFrom, dto.EffectiveTo, dto.CompanyID);
         }
     }
     catch (Exception ex)
     {
         log.Error(ex.Message + Environment.NewLine + ex.StackTrace);
         throw;
     }
 }
コード例 #14
0
        public static AgreementDto Convert(Agreement agreement)
        {
            if (agreement == null)
            {
                return(null);
            }
            AgreementDto agreementDto = new AgreementDto();

            agreementDto.RentID   = agreement.RentID;
            agreementDto.ClientID = agreement.ClientID;
            agreementDto.RoomID   = agreement.RoomID;
            agreementDto.Start    = agreement.Start;
            agreementDto.Finish   = agreement.Finish;
            agreementDto.Payday   = agreement.Payday;

            return(agreementDto);
        }
コード例 #15
0
        public void AgreementCreate(AgreementDto dto)
        {
            try
            {
                using (var db = new ONRRDatabaseEntities())
                {
                    var newId = new ObjectParameter("newId", 0);

                    var id = db.AgreementsInsert(dto.ONRRAgreementID, dto.BLMSerialNumber, dto.ONRRAgreementDescription,
                                                 dto.Formation, dto.AgreementClassificationID, dto.AgreementTypeID, dto.TotalAcreage,
                                                 dto.EffectiveFrom, dto.EffectiveTo, dto.CompanyID, newId);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                throw;
            }
        }
コード例 #16
0
ファイル: AgreementDomainService.cs プロジェクト: Nahsa7/repo
        public bool Create(AgreementDto agremmentDto)
        {
            try
            {
                _context.Agreements.Add(new Agreement()
                {
                    Description        = agremmentDto.Description,
                    DiscountAmount     = agremmentDto.DiscountAmount,
                    DiscountPercentual = agremmentDto.DiscountPercentual
                });

                _context.SaveChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #17
0
        public AgreementDto AgreementRead(int ID)
        {
            var result = new AgreementDto();

            try
            {
                using (var db = new ONRRDatabaseEntities())
                {
                    var query = db.AgreementsSelect(ID);
                    result = Mapper.Map <AgreementDto>(query.FirstOrDefault());
                }

                return(result);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message + Environment.NewLine + ex.StackTrace);
                throw;
            }
        }
コード例 #18
0
        private void btdelag_Click(object sender, RoutedEventArgs e)
        {
            AgreementDto item = dataGridAgreement.SelectedItem as AgreementDto;

            if (item == null)
            {
                MessageBox.Show("Ничего не было выбрано для удаления ╮( ̄ω ̄)╭ ", "Какой коwмар!");
                return;
            }

            MessageBoxResult result = MessageBox.Show("Сейчас произойдет удаление помещения " + item.RentID + " (×_×)", "!!!!", MessageBoxButton.YesNo);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }
            IAgreementProcess agreementProcess = ProcessFactory.GetAgreementProcess();

            agreementProcess.Delete(item.RentID);
            UpdateWND();
        }
コード例 #19
0
 public AddAgreement(AgreementDto agreement = null)
 {
     agreementdto = agreement;
     InitializeComponent();
     LoadAgreement();
 }
コード例 #20
0
 public void Add(AgreementDto agreement)
 {
     agreementDao.Add(DtoConverter.Convert(agreement));
 }
コード例 #21
0
 public void Update(AgreementDto agreement)
 {
     agreementDao.Update(DtoConverter.Convert(agreement));
 }
コード例 #22
0
        public async Task <ActionResult> Index(int id)
        {
            AgreementDto agreementDto = await agreementService.GetAgreementByIdAsync(id);

            return(View(mapper.Map <AgreementDto, AgreementModel>(agreementDto)));
        }
        public async Task <GetEmployerAgreementResponse> Handle(GetEmployerAgreementRequest message)
        {
            var validationResult = await _validator.ValidateAsync(message);

            if (validationResult.IsUnauthorized)
            {
                throw new UnauthorizedAccessException();
            }

            if (!validationResult.IsValid())
            {
                throw new InvalidRequestException(validationResult.ValidationDictionary);
            }

            var accountId   = _hashingService.DecodeValue(message.HashedAccountId);
            var agreementId = _hashingService.DecodeValue(message.AgreementId);

            var employerAgreement = await _database.Value.Agreements.ProjectTo <AgreementDto>(_configurationProvider)
                                    .SingleOrDefaultAsync(x => x.Id.Equals(agreementId));

            if (employerAgreement == null)
            {
                return(new GetEmployerAgreementResponse());
            }

            AgreementDto lastSignedAgreement = null;

            if (employerAgreement.StatusId == EmployerAgreementStatus.Pending)
            {
                lastSignedAgreement = _database.Value.Agreements
                                      .OrderByDescending(x => x.Template.VersionNumber)
                                      .ProjectTo <AgreementDto>(_configurationProvider)
                                      .FirstOrDefault(x => x.AccountId.Equals(accountId) &&
                                                      x.LegalEntityId.Equals(employerAgreement.LegalEntityId) &&
                                                      x.StatusId == EmployerAgreementStatus.Signed);
            }

            if (employerAgreement.StatusId != EmployerAgreementStatus.Signed)
            {
                employerAgreement.SignedByName = _database.Value.Memberships
                                                 .Where(m => m.AccountId == accountId && m.User.Ref.ToString() == message.ExternalUserId)
                                                 .AsEnumerable()
                                                 .Select(m => m.User.FullName)
                                                 .Single();
            }

            employerAgreement.HashedAccountId     = _hashingService.HashValue(employerAgreement.AccountId);
            employerAgreement.HashedAgreementId   = _hashingService.HashValue(employerAgreement.Id);
            employerAgreement.HashedLegalEntityId = _hashingService.HashValue(employerAgreement.LegalEntityId);

            if (lastSignedAgreement != null)
            {
                lastSignedAgreement.HashedAccountId     = _hashingService.HashValue(lastSignedAgreement.AccountId);
                lastSignedAgreement.HashedAgreementId   = _hashingService.HashValue(lastSignedAgreement.Id);
                lastSignedAgreement.HashedLegalEntityId = _hashingService.HashValue(lastSignedAgreement.LegalEntityId);
            }

            return(new GetEmployerAgreementResponse
            {
                EmployerAgreement = employerAgreement,
                LastSignedAgreement = lastSignedAgreement
            });
        }
コード例 #24
0
 public bool Update(AgreementDto agreementDto)
 {
     return(_agreementDomainService.Update(agreementDto));
 }
コード例 #25
0
 public bool Create(AgreementDto agreementDto)
 {
     return(_agreementDomainService.Create(agreementDto));
 }