Beispiel #1
0
 public string SavecounterParty(CounterParty counterParty)
 {
     using (LoanPriceEntities context = new LoanPriceEntities())
     {
         if (counterParty.ID <= 0)
         {
             if (context.CounterParties.Where(s => s.Name == counterParty.Name).Count() == 0)
             {
                 context.AddToCounterParties(counterParty);
                 context.SaveChanges();
                 return("CounterParty is added successfully");
             }
             else
             {
                 return("Entry of the same Name is already exists.");
             }
         }
         else
         {
             if (context.CounterParties.Where(s => s.Name == counterParty.Name && s.ID != counterParty.ID).Count() == 0)
             {
                 context.CounterParties.Attach(counterParty);
                 context.ObjectStateManager.ChangeObjectState(counterParty, System.Data.EntityState.Modified);
                 context.SaveChanges();
                 return("CounterParty is Updated successfully");
             }
             else
             {
                 return("Entry of the same Name is already exists.");
             }
         }
     }
 }
Beispiel #2
0
        public static List <CounterParty> GetCounterParty()
        {
            List <CounterParty> list = new List <CounterParty>();
            ISheet       sheet;
            HSSFWorkbook hssfwb = new HSSFWorkbook(File.OpenRead(HostingEnvironment.MapPath("~/SeedFiles/CounterParty.xls")));

            sheet = hssfwb.GetSheetAt(0);
            for (int row = 1; row <= sheet.LastRowNum; row++)
            {
                CounterParty con = new CounterParty();
                if (sheet.GetRow(row) != null)
                {
                    con.Name         = sheet.GetRow(row).GetCell(1).StringCellValue;
                    con.Identifier   = sheet.GetRow(row).GetCell(2).StringCellValue;
                    con.PropCode     = sheet.GetRow(row).GetCell(3).StringCellValue;
                    con.PipelineID   = 0;
                    con.IsActive     = sheet.GetRow(row).GetCell(5).NumericCellValue == 0 ? false : true;
                    con.CreatedBy    = sheet.GetRow(row).GetCell(6).StringCellValue;
                    con.CreatedDate  = DateTime.Now;
                    con.ModifiedBy   = sheet.GetRow(row).GetCell(8).StringCellValue;
                    con.ModifiedDate = DateTime.Now;
                    list.Add(con);
                }
            }
            return(list);
        }
Beispiel #3
0
        public CounterParty UpdateConterparty(CounterParty counterparty)
        {
            counterparty.CounterpartyType     = "PrivatePerson";
            counterparty.CounterpartyProperty = "Recipient";
            var result = _jsonLogic.ModifyObject <CounterParty>("Counterparty", "update",
                                                                counterparty);

            return(result);
        }
Beispiel #4
0
 public void Delete(int id)
 {
     using (LoanPriceEntities context = new LoanPriceEntities())
     {
         CounterParty group = context.CounterParties.FirstOrDefault(c => c.ID == id);
         if (group != null)
         {
             context.CounterParties.DeleteObject(group);
             context.SaveChanges();
         }
     }
 }
Beispiel #5
0
 public int GetcounterPartyFromName(string name)
 {
     using (LoanPriceEntities context = new LoanPriceEntities())
     {
         CounterParty group = context.CounterParties.FirstOrDefault(c => c.Name == name);
         if (group != null)
         {
             return(group.ID);
         }
         else
         {
             return(0);
         }
     }
 }
Beispiel #6
0
 public UPRD.DTO.CounterPartyDTO Parse(CounterParty item)
 {
     UPRD.DTO.CounterPartyDTO cp = new UPRD.DTO.CounterPartyDTO();
     cp.ID           = item.ID;
     cp.CreatedBy    = item.CreatedBy;
     cp.Identifier   = item.Identifier;
     cp.IsActive     = item.IsActive;
     cp.ModifiedBy   = item.ModifiedBy;
     cp.ModifiedDate = item.ModifiedDate;
     cp.Name         = item.Name;
     cp.PipelineID   = item.PipelineID;
     cp.PropCode     = item.PropCode;
     cp.Name         = item.Name;
     return(cp);
 }
Beispiel #7
0
        public CounterPartiesDTO Parse(CounterParty item)
        {
            CounterPartiesDTO itemObj = new CounterPartiesDTO();

            itemObj.ID           = item.ID;
            itemObj.Name         = item.Name;
            itemObj.Identifier   = item.Identifier;
            itemObj.PropCode     = item.PropCode;
            itemObj.PipeDuns     = item.PipeDuns;
            itemObj.IsActive     = item.IsActive;
            itemObj.CreatedBy    = item.CreatedBy;
            itemObj.CreatedDate  = item.CreatedDate;
            itemObj.ModifiedBy   = item.ModifiedBy;
            itemObj.ModifiedDate = item.ModifiedDate;
            return(itemObj);
        }
Beispiel #8
0
        public CounterParty Create(CounterPartyDTO item)
        {
            CounterParty C = new CounterParty();

            C.ID           = item.ID;
            C.CreatedBy    = item.CreatedBy;
            C.Identifier   = item.Identifier;
            C.IsActive     = item.IsActive;
            C.ModifiedBy   = item.ModifiedBy;
            C.ModifiedDate = item.ModifiedDate;
            C.Name         = item.Name;
            C.PipelineID   = item.PipelineID;
            C.PropCode     = item.PropCode;
            C.Name         = item.Name;
            return(C);
        }
Beispiel #9
0
    public Result <IReadOnlyList <PublisherGame> > GetNewPublisherGamesFromTrade(Instant completionTime)
    {
        var dateOfAcquisition          = completionTime.ToEasternDate();
        var proposerGameDictionary     = Proposer.PublisherGames.Where(x => x.MasterGame is not null).ToDictionary(x => x.GetMasterGameYearWithCounterPick() !);
        var counterPartyGameDictionary = CounterParty.PublisherGames.Where(x => x.MasterGame is not null).ToDictionary(x => x.GetMasterGameYearWithCounterPick() !);

        List <PotentialPublisherSlot> newlyOpenProposerSlotNumbers = new List <PotentialPublisherSlot>();

        foreach (var game in ProposerMasterGames)
        {
            var existingPublisherGame = proposerGameDictionary[game];
            newlyOpenProposerSlotNumbers.Add(new PotentialPublisherSlot(existingPublisherGame.SlotNumber, game.CounterPick));
        }
        List <PotentialPublisherSlot> newlyOpenCounterPartySlotNumbers = new List <PotentialPublisherSlot>();

        foreach (var game in CounterPartyMasterGames)
        {
            var existingPublisherGame = counterPartyGameDictionary[game];
            newlyOpenCounterPartySlotNumbers.Add(new PotentialPublisherSlot(existingPublisherGame.SlotNumber, game.CounterPick));
        }

        var alreadyOpenProposerSlotNumbers     = Proposer.GetPublisherSlots(LeagueYear.Options).Where(x => x.PublisherGame is null).Select(x => new PotentialPublisherSlot(x.SlotNumber, x.CounterPick));
        var alreadyOpenCounterPartySlotNumbers = CounterParty.GetPublisherSlots(LeagueYear.Options).Where(x => x.PublisherGame is null).Select(x => new PotentialPublisherSlot(x.SlotNumber, x.CounterPick));
        var allOpenProposerSlotNumbers         = alreadyOpenProposerSlotNumbers.Concat(newlyOpenProposerSlotNumbers).Distinct().OrderBy(x => x.CounterPick).ThenBy(x => x.SlotNumber).ToList();
        var allOpenCounterPartySlotNumbers     = alreadyOpenCounterPartySlotNumbers.Concat(newlyOpenCounterPartySlotNumbers).Distinct().OrderBy(x => x.CounterPick).ThenBy(x => x.SlotNumber).ToList();

        List <PublisherGame> newPublisherGames = new List <PublisherGame>();

        foreach (var game in ProposerMasterGames)
        {
            var existingPublisherGame = proposerGameDictionary[game];
            var eligibilityFactors    = LeagueYear.GetEligibilityFactorsForMasterGame(game.MasterGameYear.MasterGame, dateOfAcquisition);
            var openSlotNumbers       = allOpenCounterPartySlotNumbers.Where(x => x.CounterPick == game.CounterPick).Select(x => x.SlotNumber);
            var slotResult            = SlotEligibilityService.GetTradeSlotResult(CounterParty, LeagueYear.Options, game, eligibilityFactors, openSlotNumbers);
            if (!slotResult.HasValue)
            {
                return(Result.Failure <IReadOnlyList <PublisherGame> >($"Cannot find an appropriate slot for: {game.MasterGameYear.MasterGame.GameName}"));
            }

            allOpenCounterPartySlotNumbers = allOpenCounterPartySlotNumbers.Where(x => !(x.SlotNumber == slotResult.Value && x.CounterPick == game.CounterPick)).ToList();
            PublisherGame newPublisherGame = new PublisherGame(CounterParty.PublisherID, Guid.NewGuid(), game.MasterGameYear.MasterGame.GameName, completionTime,
                                                               game.CounterPick, existingPublisherGame.ManualCriticScore, existingPublisherGame.ManualWillNotRelease, existingPublisherGame.FantasyPoints, game.MasterGameYear, slotResult.Value, null, null, null, TradeID);
            newPublisherGames.Add(newPublisherGame);
        }
        foreach (var game in CounterPartyMasterGames)
        {
            var existingPublisherGame = counterPartyGameDictionary[game];
            var eligibilityFactors    = LeagueYear.GetEligibilityFactorsForMasterGame(game.MasterGameYear.MasterGame, dateOfAcquisition);
            var openSlotNumbers       = allOpenProposerSlotNumbers.Where(x => x.CounterPick == game.CounterPick).Select(x => x.SlotNumber);
            var slotResult            = SlotEligibilityService.GetTradeSlotResult(Proposer, LeagueYear.Options, game, eligibilityFactors, openSlotNumbers);
            if (!slotResult.HasValue)
            {
                return(Result.Failure <IReadOnlyList <PublisherGame> >($"Cannot find an appropriate slot for: {game.MasterGameYear.MasterGame.GameName}"));
            }

            allOpenProposerSlotNumbers = allOpenProposerSlotNumbers.Where(x => !(x.SlotNumber == slotResult.Value && x.CounterPick == game.CounterPick)).ToList();
            PublisherGame newPublisherGame = new PublisherGame(Proposer.PublisherID, Guid.NewGuid(), game.MasterGameYear.MasterGame.GameName, completionTime,
                                                               game.CounterPick, existingPublisherGame.ManualCriticScore, existingPublisherGame.ManualWillNotRelease, existingPublisherGame.FantasyPoints, game.MasterGameYear, slotResult.Value, null, null, null, TradeID);
            newPublisherGames.Add(newPublisherGame);
        }

        return(newPublisherGames);
    }