예제 #1
0
 public static WaterTransferRegistrationDto AsDto(this WaterTransferRegistration waterTransferRegistration)
 {
     return(new WaterTransferRegistrationDto
     {
         AccountID = waterTransferRegistration.AccountID,
         WaterTransferTypeID = waterTransferRegistration.WaterTransferTypeID,
         StatusDate = waterTransferRegistration.StatusDate
     });
 }
예제 #2
0
 public static WaterTransferRegistrationSimpleDto AsSimpleDto(this WaterTransferRegistration waterTransferRegistration)
 {
     return(new WaterTransferRegistrationSimpleDto
     {
         Account = waterTransferRegistration.Account.AsDto(),
         WaterTransferTypeID = waterTransferRegistration.WaterTransferTypeID,
         WaterTransferRegistrationStatusID = waterTransferRegistration.WaterTransferRegistrationStatusID,
         StatusDate = waterTransferRegistration.StatusDate,
         IsRegistered = waterTransferRegistration.IsRegistered,
         IsCanceled = waterTransferRegistration.IsCanceled,
         IsPending = waterTransferRegistration.IsPending
     });
 }
예제 #3
0
        public static WaterTransferDto CreateNew(RioDbContext dbContext, OfferDto offerDto, TradeDto tradeDto, PostingDto postingDto)
        {
            var waterTransfer = new WaterTransfer
            {
                OfferID             = offerDto.OfferID,
                AcreFeetTransferred = offerDto.Quantity,
                TransferDate        = offerDto.OfferDate
            };

            var waterTransferRegistrationBuyer = new WaterTransferRegistration()
            {
                WaterTransfer       = waterTransfer,
                WaterTransferTypeID = (int)WaterTransferTypeEnum.Buying,
                StatusDate          = DateTime.Now,
                WaterTransferRegistrationStatusID = (int)WaterTransferRegistrationStatusEnum.Pending
            };
            var waterTransferRegistrationSeller = new WaterTransferRegistration()
            {
                WaterTransfer       = waterTransfer,
                WaterTransferTypeID = (int)WaterTransferTypeEnum.Selling,
                StatusDate          = DateTime.Now,
                WaterTransferRegistrationStatusID = (int)WaterTransferRegistrationStatusEnum.Pending
            };

            if (postingDto.PostingType.PostingTypeID == (int)PostingTypeEnum.OfferToSell)
            {
                waterTransferRegistrationSeller.AccountID = postingDto.CreateAccount.AccountID;
                waterTransferRegistrationBuyer.AccountID  = tradeDto.CreateAccount.AccountID;
            }
            else
            {
                waterTransferRegistrationSeller.AccountID = tradeDto.CreateAccount.AccountID;
                waterTransferRegistrationBuyer.AccountID  = postingDto.CreateAccount.AccountID;
            }

            dbContext.WaterTransfer.Add(waterTransfer);
            dbContext.WaterTransferRegistration.Add(waterTransferRegistrationBuyer);
            dbContext.WaterTransferRegistration.Add(waterTransferRegistrationSeller);
            dbContext.SaveChanges();
            dbContext.Entry(waterTransfer).Reload();

            return(GetByWaterTransferID(dbContext, waterTransfer.WaterTransferID));
        }