public void CanUpdatePortfolio()
        {
            portfolioRepository.Setup(c => c.IsExist(It.IsAny <int>()))
            .Returns((int i) => ListPortfolios.Any(c => c.Id == i));
            portfolioRepository.Setup(m => m.Update(It.IsAny <Portfolio>()))
            .Callback <Portfolio>(p =>
            {
                int index             = ListPortfolios.IndexOf(ListPortfolios.FirstOrDefault(c => c.Id == p.Id));
                ListPortfolios[index] = p;
            });
            UnitOfWork.Setup(m => m.Portfolios).Returns(portfolioRepository.Object);
            portfolioService = new PortfolioService(UnitOfWork.Object, validateService, customerService.Object, map, positionService.Object);

            #region
            PortfolioDTO updatePortfolio = new PortfolioDTO
            {
                Id             = 1,
                Name           = "Update Portfolio",
                Notes          = "A portfolio is a grouping of financial assets such as stocks,",
                DisplayIndex   = 1,
                LastUpdateDate = new DateTime(2017, 4, 28),
                Visibility     = false,
                Quantity       = 2,
                PercentWins    = 73.23m,
                BiggestWinner  = 234.32m,
                BiggestLoser   = 12.65m,
                AvgGain        = 186.65m,
                MonthAvgGain   = 99.436m,
                PortfolioValue = 1532.42m
            };
            #endregion
            portfolioService.UpdatePortfolio(updatePortfolio);

            Assert.IsTrue(ListPortfolios.FirstOrDefault(c => c.Id == 1).Name == "Update Portfolio");
        }
        public void CanNotUpdateNullReferencePortfolio()
        {
            UnitOfWork.Setup(m => m.Portfolios).Returns(portfolioRepository.Object);
            portfolioService = new PortfolioService(UnitOfWork.Object, validateService, customerService.Object, map, positionService.Object);

            portfolioService.UpdatePortfolio((PortfolioDTO)null);
        }
        public void CanNotDeletePortfolioByNullId()
        {
            UnitOfWork.Setup(m => m.Portfolios).Returns(portfolioRepository.Object);
            portfolioService = new PortfolioService(UnitOfWork.Object, validateService, customerService.Object, map, positionService.Object);

            portfolioService.DeletePortfolio(null);
        }
        public void CanUpdatePortfolioInCreateOrUpdate()
        {
            portfolioRepository.Setup(m => m.UpdatePortfolioNameAndNotes(It.IsAny <Portfolio>()))
            .Callback <Portfolio>(p =>
            {
                int index = ListPortfolios.IndexOf(ListPortfolios.FirstOrDefault(c => c.Id == p.Id));
                ListPortfolios[index].Name  = p.Name;
                ListPortfolios[index].Notes = p.Notes;
            });
            portfolioRepository.Setup(m => m.IsExist(It.IsAny <int>()))
            .Returns((int id) => ListPortfolios.Any(p => p.Id == id));
            customerService.Setup(m => m.GetCustomerByProfileId(It.IsAny <string>()))
            .Returns(new Customer {
                Id = 23123, Name = "Misha"
            });
            UnitOfWork.Setup(m => m.Portfolios).Returns(portfolioRepository.Object);
            portfolioService = new PortfolioService(UnitOfWork.Object, validateService, customerService.Object, map, positionService.Object);

            portfolioService.CreateOrUpdatePortfolio(new PortfolioDTO {
                Id = 1, Name = "Update Name", Notes = "New Notes"
            }, "");

            Assert.IsTrue(ListPortfolios.Count() == 2);
            Assert.IsTrue(ListPortfolios.FirstOrDefault(c => c.Id == 1).Name == "Update Name");
            Assert.IsTrue(ListPortfolios.FirstOrDefault(c => c.Id == 1).Notes == "New Notes");
        }
Exemple #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int   id    = Convert.ToInt32(Request["id"]);
         User  user  = UserService.GetUser(id);
         Judge judge = UserService.GetJudge(user);
         if (null != judge)
         {
             ScoringPhase        phase = ScoreService.GetJudgeScoreStatus(judge);
             IList <JudgeStatus> list  = ScoreService.GetJudgeStatusForJudge(judge, phase, "j.Status", true);
             if (list.Count == 0)
             {
                 IList <Portfolio> apps = PortfolioService.GetPortfolios(judge.Category);
                 foreach (Portfolio a in apps)
                 {
                     if (ScoreService.IsJudgeInArea(judge, a))
                     {
                         ScoreService.BuildScoresForJudge(a, judge);
                     }
                 }
             }
             MasterPage.ShowInfoMessage("Scores created for Judge " + judge.User.FullName);
         }
     }
 }
Exemple #6
0
    protected void gvPhotos_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Portfolio          portfolio   = e.Row.DataItem as Portfolio;
            IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.Portfolio, portfolio.Id);
            Label      labStatus           = e.Row.FindControl("labStatus") as Label;
            Image      imgPhoto            = e.Row.FindControl("imgPhoto") as Image;
            LinkButton lnkDownLoad         = e.Row.FindControl("lnkDownLoad") as LinkButton;

            labStatus.Text = portfolio.Status.ToDescription();

            Attachment image = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.PersonalPhoto);
            if (null != image)
            {
                imgPhoto.ImageUrl           = "~/ImageHandler.ashx?id=" + image.Id;
                lnkDownLoad.CommandArgument = image.Id.ToString();
            }
            else
            {
                imgPhoto.Visible  = false;
                imgPhoto.ImageUrl = "";
            }
        }
    }
Exemple #7
0
        public void PortfolioService_ModifyService_Delete()
        {
            //Set up test
            var fakeService = A.Fake <IServiceDto>();

            A.CallTo(() => fakeService.Name).Returns(ServiceName);
            A.CallTo(() => fakeService.Id).Returns(ServiceId);

            var fakeServiceController = A.Fake <IServiceController>();

            A.CallTo(() => fakeServiceController.ModifyService(UserId, fakeService, EntityModification.Delete)).Returns(null);

            //Do Test Action
            PortfolioService portfolioService = new PortfolioService(A.Fake <IServiceBundleController>(), fakeServiceController, A.Fake <ILifecycleStatusController>()
                                                                     , A.Fake <IServiceSwotController>(), A.Fake <ISwotActivityController>(), A.Fake <IServiceDocumentController>(), A.Fake <IServiceGoalController>()
                                                                     , A.Fake <IServiceContractController>(), A.Fake <IServiceWorkUnitController>(), A.Fake <IServiceMeasureController>(), A.Fake <IServiceOptionController>()
                                                                     , A.Fake <IServiceOptionCategoryController>(), A.Fake <IServiceProcessController>(), A.Fake <ITextInputController>(), A.Fake <ISelectionInputController>()
                                                                     , A.Fake <IScriptedSelectionInputController>(), A.Fake <IServiceRequestPackageController>());
            var result = portfolioService.ModifyService(UserId, fakeService, EntityModification.Delete);

            //Clean up before Assert in case the Assert Fails and you dont reach code beyond it... If you want

            //Assert
            Assert.Null(result);
        }
Exemple #8
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        FileUpload fileUpload = modalImageDlg.FindControl("txtFileUpload") as FileUpload;

        if (null != fileUpload && fileUpload.HasFile)
        {
            IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.User, CurrentUser.Id);
            Attachment         image       = null;
            if (null != attachments && attachments.Count > 0)
            {
                image = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.GroupPhoto);
            }
            if (null == image)
            {
                image             = new Attachment();
                image.Category    = AttachmentCategory.GroupPhoto;
                image.Type        = AttachmentType.User;
                image.ObjectRowId = CurrentUser.Id;
                image.Description = "Group Picture";
            }
            image.Name = fileUpload.FileName;
            using (BinaryReader reader = new BinaryReader(fileUpload.FileContent))
            {
                byte[] buf = reader.ReadBytes((int)fileUpload.FileContent.Length);
                fileUpload.FileContent.Close();
                image.Data = buf;// ImageUtils.NormalizeImage(buf);
                reader.Close();
            }
            PortfolioService.SaveAttachment(image);
            imgPhoto.Visible  = true;
            imgPhoto.ImageUrl = "~/ImageHandler.ashx?id=" + image.Id;
        }
        modalImageDlg.HideModal();
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!(Page.IsPostBack))
     {
         string strXML;
         PortfolioService objectService = new PortfolioService();
         string strParam = Session["selectedstock"].ToString();
         strXML = objectService.GetStockInfoByTicker(strParam);
         XElement xmlstockrecord = XElement.Parse(strXML);
         XElement xmlstock = xmlstockrecord.Element("Stock");
         XElement xmlstockticker = xmlstock.Element("Ticker");
         XElement xmlstockCusip = xmlstock.Element("Cusip");
         XElement xmlstockVolume = xmlstock.Element("Volume");
         XElement xmlstockEPS = xmlstock.Element("EPS");
         XElement xmlstockSector = xmlstock.Element("Sector");
         XElement xmlstockCompanyName = xmlstock.Element("CompanyName");
         XElement xmlstockCountry = xmlstock.Element("Country");
         
         lblTicker.Text = xmlstockticker.Value.ToString();
         lblCusip.Text = xmlstockCusip.Value.ToString();
         lblVolume.Text = xmlstockVolume.Value.ToString();
         lblEps.Text = xmlstockEPS.Value.ToString();
         lblSector.Text = xmlstockSector.Value.ToString();
         lblCompany.Text = xmlstockCompanyName.Value.ToString();
         lblCountry.Text = xmlstockCountry.Value.ToString();
         
     }
 }
Exemple #10
0
        public async Task <IHttpActionResult> Get()
        {
            PortfolioService portService = CreatePortfolioService();
            var posts = await portService.GetPortfolio();

            return(Ok(posts));
        }
        public void When_Updating_Portfolio_With_Invalid_Transaction_Then_Exception_Is_Thrown()
        {
            // setup
            var      portfolio        = TestDataGenerator.GenerateEmptyPortfolio();
            var      portfolioService = new PortfolioService(portfolio);
            Security goog             = new Security {
                Symbol = "goog"
            };
            var transaction = new Transaction
            {
                Account  = null,
                Date     = DateTime.UtcNow,
                Price    = 0M,
                Security = goog,
                Shares   = 10M,
                Type     = TransactionType.Buy
            };

            // verify
            try
            {
                portfolioService.UpdateWith(new List <Transaction> {
                    transaction
                });
            }
            catch (Exception ex)
            {
                Assert.That(ex.Message, Is.EqualTo("One or more transactions are invalid."));
            }
        }
Exemple #12
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string arg = String.Empty;

        if (sender is Button && !String.IsNullOrEmpty(((Button)sender).CommandArgument))
        {
            arg = ((Button)sender).CommandArgument;
        }
        if (!String.IsNullOrEmpty(arg))
        {
            this.Validate(arg);
        }
        else
        {
            this.Validate();
        }
        if (this.IsValid)
        {
            SavePortfolio(AccordianControl.SelectedIndex);
            MissingItems = PortfolioService.GetMissingItems(GetPortfolio());
            if (AccordianControl.SelectedIndex < AccordianControl.Panes.Count)
            {
                AccordianControl.SelectedIndex += 1;
            }
            else
            {
                AccordianControl.SelectedIndex = 0;
            }
        }
    }
        public void When_Updating_Account_With_Sell_Transaction_But_No_Position_Then_Exception_Is_Thrown()
        {
            // setup
            var      portfolio        = TestDataGenerator.GenerateEmptyPortfolio();
            var      mandingo         = portfolio.Accounts.Single(a => a.Name.Equals("mandingo", StringComparison.InvariantCultureIgnoreCase));
            var      portfolioService = new PortfolioService(portfolio);
            Security goog             = new Security {
                Symbol = "goog"
            };
            var transaction = new Transaction
            {
                Account  = mandingo,
                Date     = DateTime.UtcNow,
                Price    = 0M,
                Security = goog,
                Shares   = 10M,
                Type     = TransactionType.Sell
            };

            // verify
            try
            {
                portfolioService.UpdateWith(new List <Transaction> {
                    transaction
                });
            }
            catch (Exception ex)
            {
                Assert.That(ex.Message, Is.EqualTo("Tried to sell a security the account doesn't have."));
            }
        }
Exemple #14
0
    protected void gvCoordinators_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DisplayUser ds     = e.Row.DataItem as DisplayUser;
            User        user   = UserService.GetUser(ds.Id);
            School      school = RegionService.GetSchoolByUser(user);

            Label      labSchool   = e.Row.FindControl("labSchool") as Label;
            Label      labCaption  = e.Row.FindControl("labCaption") as Label;
            Image      imgPhoto    = e.Row.FindControl("imgGroupPhoto") as Image;
            LinkButton lnkDownLoad = e.Row.FindControl("lnkDownLoad") as LinkButton;

            labSchool.Text = school.Name;

            IList <Attachment> attachments = PortfolioService.GetAttachments(AttachmentType.User, user.Id);
            Attachment         image       = attachments.FirstOrDefault(x => x.Category == AttachmentCategory.GroupPhoto);
            if (null != image)
            {
                imgPhoto.Visible            = true;
                imgPhoto.ImageUrl           = "~/ImageHandler.ashx?id=" + image.Id;
                lnkDownLoad.CommandArgument = image.Id.ToString();
            }
            IList <KeyValue> keyValues = PortfolioService.GetKeyValues(ObjectTypes.User, user.Id);
            var val = keyValues.FirstOrDefault(x => "GroupCaption".Equals(x.KeyName) && x.Type == KeyValueType.String);
            if (val != null)
            {
                labCaption.Text = val.StringValue;
            }
        }
    }
Exemple #15
0
        public void PortfolioService_GetServiceDocuments()
        {
            //Set up test
            var fakeService = A.Fake <IServiceDto>();

            A.CallTo(() => fakeService.Name).Returns(ServiceName);
            A.CallTo(() => fakeService.Id).Returns(ServiceId);

            var fakeDocument = A.Fake <IServiceDocumentDto>();

            A.CallTo(() => fakeDocument.Id).Returns(ServiceDocumentId);
            A.CallTo(() => fakeDocument.ServiceId).Returns(ServiceId);
            A.CallTo(() => fakeDocument.UploadDate).Returns(DateTime.UtcNow);

            var fakeServiceController = A.Fake <IServiceController>();

            A.CallTo(() => fakeServiceController.GetServiceDocuments(ServiceId)).Returns(new List <IServiceDocumentDto>()
            {
                fakeDocument
            });

            //Do Test Action
            PortfolioService portfolioService = new PortfolioService(A.Fake <IServiceBundleController>(), fakeServiceController, A.Fake <ILifecycleStatusController>()
                                                                     , A.Fake <IServiceSwotController>(), A.Fake <ISwotActivityController>(), A.Fake <IServiceDocumentController>(), A.Fake <IServiceGoalController>()
                                                                     , A.Fake <IServiceContractController>(), A.Fake <IServiceWorkUnitController>(), A.Fake <IServiceMeasureController>(), A.Fake <IServiceOptionController>()
                                                                     , A.Fake <IServiceOptionCategoryController>(), A.Fake <IServiceProcessController>(), A.Fake <ITextInputController>(), A.Fake <ISelectionInputController>()
                                                                     , A.Fake <IScriptedSelectionInputController>(), A.Fake <IServiceRequestPackageController>());
            var result = portfolioService.GetServiceDocuments(ServiceId);

            //Clean up before Assert in case the Assert Fails and you dont reach code beyond it... If you want

            //Assert
            Assert.True(result.Any(x => x.Id == ServiceDocumentId));
        }
Exemple #16
0
        public void PortfolioService_GetServicesForServiceBundle()
        {
            //Set up test
            var fakeService = A.Fake <IServiceDto>();

            A.CallTo(() => fakeService.Name).Returns(ServiceName);
            A.CallTo(() => fakeService.Id).Returns(ServiceId);

            var fakeServiceController = A.Fake <IServiceController>();

            A.CallTo(() => fakeServiceController.GetServicesForServiceBundle(_serviceBundleId.Value)).Returns(new List <IServiceDto>()
            {
                fakeService
            });

            //Do Test Action
            PortfolioService portfolioService = new PortfolioService(A.Fake <IServiceBundleController>(), fakeServiceController, A.Fake <ILifecycleStatusController>()
                                                                     , A.Fake <IServiceSwotController>(), A.Fake <ISwotActivityController>(), A.Fake <IServiceDocumentController>(), A.Fake <IServiceGoalController>()
                                                                     , A.Fake <IServiceContractController>(), A.Fake <IServiceWorkUnitController>(), A.Fake <IServiceMeasureController>(), A.Fake <IServiceOptionController>()
                                                                     , A.Fake <IServiceOptionCategoryController>(), A.Fake <IServiceProcessController>(), A.Fake <ITextInputController>(), A.Fake <ISelectionInputController>()
                                                                     , A.Fake <IScriptedSelectionInputController>(), A.Fake <IServiceRequestPackageController>());
            var result = portfolioService.GetServicesForServiceBundle(ServiceId);

            //Clean up before Assert in case the Assert Fails and you dont reach code beyond it... If you wPortfolioService controllerant

            //Assert
            Assert.Equal(ServiceId, result.First().Id);
        }
        public void Init()
        {
            _dbcontext    = new Mock <PortfolioDbContext>();
            _liveDataRepo = new Mock <ILiveDataRepository>();

            portfolioService = new PortfolioService(_dbcontext.Object, _liveDataRepo.Object);
        }
Exemple #18
0
        private PortfolioService CreatePortfolioService()
        {
            var userId      = Guid.Parse(User.Identity.GetUserId());
            var portService = new PortfolioService(userId);

            return(portService);
        }
Exemple #19
0
 static Program()
 {
     client           = CreateClient(GetTokenDictionary("Admin", "Password")["access_token"]);
     portfolioService = new PortfolioService(path, client);
     positionService  = new PositionService(path, client);
     userService      = new UserService(path, client);
 }
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                MainService.Startup();
                Globals.SetTheme(this);

                _coinConfigs        = PortfolioService.LoadStartup();
                cbCurrency.Text     = UserConfigService.Currency;
                txtRefreshTime.Text = (UserConfigService.RefreshTime / 1000).ToString();
                SetupPortfolioMenu();

                ThreadStarter(new Thread(new ThreadStart(CheckUpdate)));
                ThreadStarter(new Thread(new ThreadStart(Timers)));
                ThreadStarter(new Thread(new ThreadStart(GetCoinData)));
            }
            catch (Exception)
            {
                if (MessageBox.Show($"There was an error starting up. Would you like to reset? \nThis will remove encryption and delete all portfolios and alerts.", "Error on startup", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                {
                    MainService.Reset();
                }

                Close();
            }
        }
        public void Setup()
        {
            var mockHttp = new MockHttpMessageHandler();
            var client   = mockHttp.ToHttpClient();

            var context = TestHelpers.GetMockFinanceDbContext();

            _financeDataService = new FinanceDataService(context);
            var balanceService = new BalanceService(_financeDataService);

            TestHelpers.SeedApp(context);

            var stockMarketApi  = new StockMarketAPI(client);
            var stockMarketData = new StockMarketData(stockMarketApi);
            var assetFactory    = new AssetsFactory(_financeDataService, stockMarketData);

            var portfolioService = new PortfolioService(_financeDataService, balanceService, assetFactory);

            _aggregatePortfolioService = new AggregatePortfolioService(portfolioService, balanceService);

            TestHelpers.MockStockData(mockHttp);
            TestHelpers.MockFondData(mockHttp);
            TestHelpers.MockBondData(mockHttp);

            TestHelpers.SeedOperations2(context);
        }
Exemple #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string id = Request["id"];

        if (null != id)
        {
            IApplicationContext ctx = Spring.Context.Support.ContextRegistry.GetContext();
            PortfolioService    portfolioService = ctx["PortfolioService"] as PortfolioService;
            Attachment          attachment       = portfolioService.GetAttachment(Convert.ToInt32(id));
            if (null != attachment)
            {
                Response.Clear();
                string ext = Path.GetExtension(attachment.Name).Replace(".", "");
                try
                {
                    string mimeType = ApacheMimeTypes.MimeTypes[ext];
                    Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", attachment.Name));
                    if (null != mimeType)
                    {
                        Response.ContentType = mimeType;
                    }
                }
                catch
                {
                    Response.ContentType = "text/plain";
                }
                Response.BinaryWrite(attachment.Data);
                Response.End();
            }
        }
    }
        public void When_Updating_Account_With_Buy_Transaction_Then_Position_Is_Added_To()
        {
            // setup
            Security goog = new Security {
                Symbol = "goog"
            };
            var portfolio = TestDataGenerator.GenerateEmptyPortfolio();
            var mandingo  = portfolio.Accounts.Single(a => a.Name.Equals("mandingo", StringComparison.InvariantCultureIgnoreCase));

            mandingo.Positions.Add(new Position
            {
                Account  = mandingo,
                Shares   = 100M,
                Security = goog
            });
            var portfolioService = new PortfolioService(portfolio);
            var transaction      = new Transaction
            {
                Account  = mandingo,
                Date     = DateTime.UtcNow,
                Price    = 0M,
                Security = goog,
                Shares   = 10M,
                Type     = TransactionType.Buy
            };

            // verify
            portfolioService.UpdateWith(new List <Transaction> {
                transaction
            });

            // verify
            Assert.That(mandingo.Positions.Single().Shares, Is.EqualTo(110M));
        }
Exemple #24
0
 private void SaveTestScores(Portfolio portfolio)
 {
     if (!string.IsNullOrEmpty(txtACTEnglish.Text))
     {
         PortfolioService.SaveKeyValue(portfolio, "ACTEnglish", txtACTEnglish.Text);
     }
     if (!string.IsNullOrEmpty(txtACTMath.Text))
     {
         PortfolioService.SaveKeyValue(portfolio, "ACTMath", txtACTMath.Text);
     }
     if (!string.IsNullOrEmpty(txtACTReading.Text))
     {
         PortfolioService.SaveKeyValue(portfolio, "ACTReading", txtACTReading.Text);
     }
     if (!string.IsNullOrEmpty(txtACTScience.Text))
     {
         PortfolioService.SaveKeyValue(portfolio, "ACTScience", txtACTScience.Text);
     }
     if (!string.IsNullOrEmpty(txtACTComposite.Text))
     {
         PortfolioService.SaveKeyValue(portfolio, "ACTComposite", txtACTComposite.Text);
     }
     if (!string.IsNullOrEmpty(txtSATReading.Text))
     {
         PortfolioService.SaveKeyValue(portfolio, "SATReading", txtSATReading.Text);
     }
     if (!string.IsNullOrEmpty(txtSATMath.Text))
     {
         PortfolioService.SaveKeyValue(portfolio, "SATMath", txtSATMath.Text);
     }
     if (!string.IsNullOrEmpty(txtSATWriting.Text))
     {
         PortfolioService.SaveKeyValue(portfolio, "SATWriting", txtSATWriting.Text);
     }
 }
Exemple #25
0
    protected void gvNominees_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        // Retrieve the row being edited.
        int          index          = gvNominees.EditIndex;
        GridViewRow  row            = gvNominees.Rows[index];
        DropDownList ddlEditStatus  = row.FindControl("ddlEditStatus") as DropDownList;
        TextBox      txtEditScore   = row.FindControl("txtEditScore") as TextBox;
        TextBox      txtEditRanking = row.FindControl("txtEditRanking") as TextBox;
        int          id             = Convert.ToInt32(gvNominees.DataKeys[e.RowIndex].Value);
        Portfolio    p = PortfolioService.GetPortfolio(id);

        if (null != p)
        {
            p.Status     = (Status)Enum.Parse(typeof(Status), ddlEditStatus.SelectedValue);
            p.TotalScore = Convert.ToDouble(txtEditScore.Text);
            p.Ranking    = Convert.ToInt32(txtEditRanking.Text);
            PortfolioService.Save(p);
            e.Cancel             = false;
            gvNominees.EditIndex = -1;
        }
        else
        {
            e.Cancel = true;
        }
        LoadNominees();
    }
Exemple #26
0
    /// <summary>
    /// Link to page
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gvNominees_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int       id        = Convert.ToInt32(gvNominees.DataKeys[0].Values[0]);
        Portfolio portfolio = null;

        if (!"".Equals(e.CommandArgument))
        {
            id        = Convert.ToInt32(e.CommandArgument);
            portfolio = PortfolioService.GetPortfolio(id);
        }
        if ("Select".Equals(e.CommandName))
        {
            Response.Redirect("StudentEdit.aspx?id=" + id.ToString());
        }
        if ("DeleteUser".Equals(e.CommandName))
        {
            if (portfolio != null)
            {
                PortfolioService.Delete(portfolio);
                UserService.DeleteUser(portfolio.User);
                LoadApplications();
            }
        }
        if ("ViewPortfolio".Equals(e.CommandName))
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=JavaScript id='openit'>");
            sb.Append("window.open('../ReportView.aspx?report=profile&id=" + portfolio.Id + "', '', '');");
            sb.Append("</script>");
            if (!ClientScript.IsStartupScriptRegistered("openit"))
            {
                ClientScript.RegisterStartupScript(this.GetType(), "openit", sb.ToString());
            }
        }
        if ("CertifyStudent".Equals(e.CommandName))
        {
            if (portfolio != null)
            {
                Label lblName     = mdlDlgPrincipal.FindControl("lblName") as Label;
                Label lblId       = mdlDlgPrincipal.FindControl("lblId") as Label;
                Label lblSchool   = mdlDlgPrincipal.FindControl("lblSchool") as Label;
                Label lblCategory = mdlDlgPrincipal.FindControl("lblCategory") as Label;
                lblId.Text       = id.ToString();
                lblName.Text     = portfolio.User.FullName;
                lblSchool.Text   = portfolio.School.Name;
                lblCategory.Text = portfolio.Category.Name;
                mdlDlgPrincipal.ShowModal();
            }
        }
        if ("CheckStatus".Equals(e.CommandName))
        {
            if (portfolio.Status == Status.Certified)
            {
                Label lblId = mdlDlgPrincipal.FindControl("lblId") as Label;
                lblId.Text = portfolio.Id.ToString();
                btnReport_Click(null, null);
            }
        }
    }
Exemple #27
0
    private void LoadPhotos()
    {
        IList <Portfolio> list = PortfolioService.GetPortfolios(GetWhereClause());

        gvPhotos.DataSource = list;
        gvPhotos.DataBind();
        lblRecCount.Text = string.Format("{0:d} nominees found", list.Count);
    }
Exemple #28
0
        public void PortfolioNotFound()
        {
            var service = new PortfolioService(null);

            var result = service.ChangeDrpParticipation(Guid.NewGuid(), true);

            result.Should().HaveNotFoundStatus();
        }
Exemple #29
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        FileUpload fileUpload            = modalDialog.FindControl("txtFileUpload") as FileUpload;
        Label      lblAttachmentCategory = modalDialog.FindControl("lblAttachmentCategory") as Label;
        Label      lblUploadInstructions = modalDialog.FindControl("lblUploadInstructions") as Label;
        Label      lblAttachmentName     = modalDialog.FindControl("lblAttachmentName") as Label;
        Label      lblAttachmentId       = modalDialog.FindControl("lblAttachmentId") as Label;

        AttachmentCategory category = (AttachmentCategory)Enum.Parse(typeof(AttachmentCategory), lblAttachmentCategory.Text);

        this.Validate("Upload");
        if (this.IsValid && null != fileUpload && fileUpload.HasFile && FileUtils.IsValidFile(fileUpload.FileName))
        {
            int        id         = Convert.ToInt32(lblAttachmentId.Text);
            Attachment attachment = null;
            if (id > 0)
            {
                attachment = PortfolioService.GetAttachment(id);
            }
            if (id <= 0 || null == attachment)
            {
                attachment = new Attachment();
                Portfolio portfolio = GetPortfolio();
                if (category == AttachmentCategory.Image || category == AttachmentCategory.Document || category == AttachmentCategory.Media)
                {
                    attachment.Type        = AttachmentType.Portfolio;
                    attachment.ObjectRowId = portfolio.Id;
                }
                else
                {
                    attachment.Type        = AttachmentType.Portfolio;
                    attachment.ObjectRowId = GetPortfolio().Id;
                }
                attachment.Category = category;
            }

            attachment.Description = lblAttachmentName.Text;
            attachment.Name        = fileUpload.FileName;

            using (BinaryReader reader = new BinaryReader(fileUpload.FileContent))
            {
                byte[] buf = reader.ReadBytes((int)fileUpload.FileContent.Length);
                reader.Close();
                fileUpload.FileContent.Close();
                if (FileUtils.IsImageFile(attachment.Name))
                {
                    attachment.Data = buf;// ImageUtils.NormalizeImage(buf);
                }
                else
                {
                    attachment.Data = buf;
                }
            }
            PortfolioService.SaveAttachment(attachment);
            modalDialog.HideModal();
            LoadPortfolio();
        }
    }
Exemple #30
0
 public ActionResult <Portfolio> Create([FromBody] Portfolio portfolio)
 {
     if (portfolio.UserId != User.GetId())
     {
         return(Conflict());
     }
     portfolio = PortfolioService.Create(portfolio);
     return(CreatedAtAction(nameof(GetById), new { id = portfolio.Id }, portfolio));
 }
Exemple #31
0
 public ActionResult <Portfolio> Update([FromBody] Portfolio portfolio)
 {
     portfolio = PortfolioService.Update(portfolio, User.GetId());
     if (portfolio == null)
     {
         return(NotFound());
     }
     return(Ok(portfolio));
 }
    public void CallStock()
    {
        PortfolioService wsbobjservice = new PortfolioService();
        string strusername = Session["username"].ToString();
        String strportfolio = wsbobjservice.GetPortfolioByUserName(strusername);
        XElement portfolio = XElement.Parse(strportfolio);


        var query = from t in portfolio.Elements("Stock")
                    select new
                    {
                        Ticker = t.Element("Ticker").Value,
                        companyname = t.Element("CompanyName").Value,
                        country = t.Element("Country").Value
                    };
        int count1 = query.Count();
        if(count1==2)
        {

            String ticker1 = query.First().Ticker;
            String ticker2 = query.Last().Ticker;
                Session["ticker1"] = ticker1;
                 Session["ticker2"] = ticker2;
            }
       
        


        gvPortfolio.DataSource = query;
        gvPortfolio.DataBind();

        String stremployee = wsbobjservice.GetEmployeeIDByUserName(strusername);
        XElement employee = XElement.Parse(stremployee);

        string strPath = Request.PhysicalApplicationPath;
        employee.Save(strPath + "employee.xml");
        //Response.Write("<a href='employee.xml'>View employee</a>");

        var query1 = from c in employee.Elements("Customer")
                     select new
                    {
                        EMP_ID = c.Element("EMP_ID").Value,
                    };
        
        

        string empid = query1.First().EMP_ID;
        if (empid != null)
        {
            EmpId = Convert.ToInt32(empid);
        }
        //GridView1.DataSource = query1;
        //GridView1.DataBind();
    }
Exemple #33
0
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Request.QueryString["EmpId"] != null)
        {
            Emp_id.Text = Request.QueryString["EmpId"];
        }

        PortfolioService objwebservice = new PortfolioService();

        string stremp_id = Session["selEmployee"].ToString();

        string strXML = objwebservice.GetEmployeeDetailByEmpID(stremp_id);

        XElement xmlemprecord = XElement.Parse(strXML);

        XElement xmlemp = xmlemprecord.Element("Employee");

        XElement xmlmanagers = xmlemp.Element("Managers");

        XElement xmlmanager = xmlmanagers.Element("Manager");

        XElement xmlmgrfrstname = xmlmanager.Element("FirstName");

        XElement xmlmgrlastname = xmlmanager.Element("LastName");

        //XElement xmlmgrid = xmlmanager.Element("ID");

        tbxmgrfrstname.Text = xmlmgrfrstname.Value.ToString();

        tbxmgrlastname.Text = xmlmgrlastname.Value.ToString();

        //tbxmgrid.Text = xmlmgrid.Value.ToString();

        
        XElement xmldirectrep = xmlemp.Element("DirectReports");

        var query = from p in xmldirectrep.Elements("Report")
                    select new
                    {
                        FirstName = p.Element("FirstName").Value,
                        LastName = p.Element("LastName").Value,
                        ID = p.Element("ID").Value
                    };

        GridView1.DataSource = query;
        GridView1.DataBind(); 

    }
    protected void Add_Click(object sender, EventArgs e)
    {
        PortfolioService objectService = new PortfolioService();

        String strusername = Session["username"].ToString();

        String strcompany = lblCompany.Text;

        String strcountry = lblCountry.Text;

        String straddedportfolio = objectService.AddStockToCustomerPortfolio(strusername, strcompany, strcountry);

        Response.Redirect("CustomerPortfolio.aspx");

     }
Exemple #35
0
     protected void Page_Load(object sender, EventArgs e)
    {
         string strXML;
         PortfolioService objectService = new PortfolioService();
         if (Request.QueryString.ToString().Contains("company"))
         {
             strXML = objectService.GetStockInfoByCompanyName(Request.QueryString["company"]);
         }
         else if (Request.QueryString.ToString().Contains("ticker"))
         {

             strXML = objectService.GetStockInfoByTicker(Request.QueryString["ticker"]);
         }
         else
             strXML = objectService.GetStockInfoByCUSIP(Request.QueryString["cusip"]);
            
        XElement stock = XElement.Parse(strXML);
       var query = from c in stock.Elements("Stock")
                    select new { Ticker = c.Element("Ticker").Value,
                                 Company= c.Element("CompanyName").Value,
                                 Country = c.Element("Country").Value
                               };
       string strPath = Request.PhysicalApplicationPath;
     //  stock.Save(strPath + "securityoffers.xml");
      // Response.Write("<a href='securityoffers.xml'>View XML file</a>");
       int count1 = query.Count();
            if  (count1 == 0)
            {
                Label1.Visible = true;
                Label1.Text = "No record Found.";
                HyperLink1.Visible = true;
                HyperLink1.Text = "Click to go back To Previous Page";
                HyperLink1.NavigateUrl = "~/SearchStock.aspx";

            }
       
       gvstock.DataSource = query;
       gvstock.DataBind();
       if (count1 == 1)
       {
           Session["selectedstock"] = query.First().Ticker;
           Response.Redirect("DisplayDetailStock.aspx");
       }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["EMP_ID"] != null)
        {
           lblSelected.Text = Request.QueryString["EMP_ID"];

        }
        
        PortfolioService objwebservice = new PortfolioService();


        string strCodeParam = Session["EMP_ID"].ToString();
        string strCodeParam1 = Session["EMP_ID"].ToString();

        string strXML = objwebservice.GetEmployeeDetailByEmpID(strCodeParam);

        XElement xmlemprecord = XElement.Parse(strXML);

        XElement xmlemp = xmlemprecord.Element("Employee");

        
        XElement xmlfirstname = xmlemp.Element("FirstName");
        XElement xmllastname  = xmlemp.Element("LastName");
        XElement xmlemail = xmlemp.Element("Email");
        XElement xmlSSN = xmlemp.Element("SSN");
        XElement xmlWorkPhone = xmlemp.Element("WorkPhone");
        XElement xmlHomePhone = xmlemp.Element("HomePhone");
        XElement xmldob = xmlemp.Element("DOB");
        XElement xmlAddress = xmlemp.Element("Address");

        tbxfirstName.Text = xmlfirstname.Value.ToString();
        tbxlastName.Text = xmllastname.Value.ToString();
        tbxdob.Text = xmldob.Value.ToString();
        lblEmail.Text = xmlemail.Value.ToString();
        lblSSN.Text = xmlSSN.Value.ToString();
        lblAddress.Text = xmlAddress.Value.ToString();
        lblWork.Text = xmlWorkPhone.Value.ToString();
        lblHome.Text = xmlHomePhone.Value.ToString();
    }
Exemple #37
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        PortfolioService objectService = new PortfolioService();
        string strUsername = TextBox1.Text.ToString();
        string strPassword = TextBox2.Text.ToString();
        string strXML = objectService.IsValidUser(strUsername, strPassword);
        XElement UsernameRecord = XElement.Parse(strXML);
      //  string strPath = Request.PhysicalApplicationPath;
        //UsernameRecord.Save(strPath + "validuser.xml");
        //Response.Write("<a href='validuser.xml'>View XML1 file</a>");


        //  XElement XMLvalidation = UsernameRecord.Element("Validation");
        XElement isValid = UsernameRecord.Element("IsValid");
        string strValid = isValid.Value.ToString();
        //  Label1.Text = strValid;

        if (strValid.Equals("True"))
        {
            Label1.Text = "Login Successful";
            Session["username"] = strUsername;
            Response.Redirect("CustomerPortfolio.aspx");
            

        }
        else
            if (strValid.Equals("False"))
            {
                {
                    Label1.Text = "Login failed";
                }



            }
    
    }
 public PortfolioController(PortfolioService portfolioServ)
 {
     _portfolioServ = portfolioServ;
 }
     //protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
     //{
     //    Session["EMP_ID"] = GridView1.SelectedDataKey.Value.ToString();
     //    Response.Redirect("Employeedetail.aspx?EMP_ID=" + GridView1.SelectedPersistedDataKey.Value); 
     //}

     protected void btnRelMan_Click1(object sender, EventArgs e)
     {
         Panel2.Visible = true;
         if (EmpId > 0)
         {
             lblSelected.Text = EmpId.ToString();

             PortfolioService objwebservice = new PortfolioService();
             string strXML = objwebservice.GetEmployeeDetailByEmpID(lblSelected.Text);
             XElement xmlemprecord = XElement.Parse(strXML);
             XElement xmlemp = xmlemprecord.Element("Employee");
             XElement xmlfirstname = xmlemp.Element("FirstName");
             XElement xmllastname = xmlemp.Element("LastName");
             XElement xmlemail = xmlemp.Element("Email");
             XElement xmlSSN = xmlemp.Element("SSN");
             XElement xmlWorkPhone = xmlemp.Element("WorkPhone");
             XElement xmlHomePhone = xmlemp.Element("HomePhone");
             XElement xmldob = xmlemp.Element("DOB");
             XElement xmlAddress = xmlemp.Element("Address");

             tbxfirstName.Text = xmlfirstname.Value.ToString();
             tbxlastName.Text = xmllastname.Value.ToString();
             tbxdob.Text = xmldob.Value.ToString();
             lblEmail.Text = xmlemail.Value.ToString();
             lblSSN.Text = xmlSSN.Value.ToString();
             lblAddress.Text = xmlAddress.Value.ToString();
             lblWork.Text = xmlWorkPhone.Value.ToString();
             lblHome.Text = xmlHomePhone.Value.ToString();
         }
     }
 protected void gvPortfolio_SelectedIndexChanged1(object sender, EventArgs e)
 {
           PortfolioService objectService1 = new PortfolioService();
           string strusername = Session["username"].ToString();
            string strxml1 = objectService1.RemoveStockFromCustomerPortfolio(strusername, gvPortfolio.SelectedRow.Cells[2].Text.ToString(), gvPortfolio.SelectedRow.Cells[3].Text.ToString());
            XElement xmlstockrecord = XElement.Parse(strxml1);
            CallStock();
           
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     PortfolioService objectService = new PortfolioService();
     string strParam = Session["deletedstock"].ToString();
     
 }
Exemple #42
0
    private void Page_Load(object sender, System.EventArgs e)
    {

        float Er1 = 0.0f;
        float Er2 = 0.0f;
        float Sd1 = 0.0f;
        float Sd2 = 0.0f;
        XElement ExpRet1 = null;
        XElement ExpRet2 = null;
        XElement StdDev1 = null;
        XElement StdDev2 = null;
        string ticker1 = Session["ticker1"].ToString();
        string ticker2 = Session["ticker2"].ToString();
        PortfolioService objectService = new PortfolioService();
        string strXML = objectService.GetStockPairInformation(ticker1, ticker2);
        XElement stock_record = XElement.Parse(strXML);
        string strPath = Request.PhysicalApplicationPath;
        stock_record.Save(strPath + "portfolio_record.xml");
     //   Response.Write("<a href='portfolio_record.xml'>View XML1 file</a>");
        XElement isCoorelation = stock_record.Element("Coorelation");

       


        var tickStock = from stock in stock_record.XPathSelectElements("//Stock")
                        select stock;

        XElement isStock1 = stock_record.Element("Stock");

        foreach (XElement stock in tickStock)
        {

            XAttribute attri1 = stock.Attribute("TickerSymbol");
            if (attri1.Value.ToString().Equals(ticker1))
            {

                ExpRet1 = stock.Element("ExpectedReturn");
                StdDev1 = stock.Element("StandarDeviation");

                //Label2.Text = ExpRet1.Value.ToString();
                //Label3.Text = StdDev1.Value.ToString();

            }
            if (attri1.Value.ToString().Equals(ticker2))
            {

                ExpRet2 = stock.Element("ExpectedReturn");
                StdDev2 = stock.Element("StandarDeviation");
               // Label4.Text = ExpRet2.Value.ToString();
                //Label5.Text = StdDev2.Value.ToString();
            }

        }



        float Corr = (float.Parse(isCoorelation.Value.ToString())) * 0.1f;

        Label1.Text = Corr.ToString();

        Er1 = float.Parse(ExpRet1.Value.ToString());
        Er2 = float.Parse(ExpRet2.Value.ToString());
        Sd1 = float.Parse(StdDev1.Value.ToString());
        Sd2 = float.Parse(StdDev2.Value.ToString());



        float[] W1 = new float[] { 1, .8f, .6f, .4f, .2f, 0 };
        float[] W2 = new float[] { 0, .2f, .4f, .6f, .8f, 1 };
        float[] Erp = new float[6];
        float[] Risk = new float[6];
        //float Er1 = .11f;
        // float Er2 = .25f;
        //  float Sd1 = .15f;
        // float Sd2 = .2f;
        // float Corr = .3f;
        TableRow tHead = new TableRow();

        riskReward.Rows.Add(tHead);
        TableCell weight1 = new TableCell();
        TableCell weight2 = new TableCell();
        TableCell risk = new TableCell();
        TableCell reward = new TableCell();
        weight1.Text = ticker1;
        weight2.Text = ticker2;
        risk.Text = "Risk";
        reward.Text = "Expected Return";
        tHead.Cells.Add(weight1);
        tHead.Cells.Add(weight2);
        tHead.Cells.Add(risk);
        tHead.Cells.Add(reward);



        for (int i = 0; i < 6; i++)
        {
            Erp[i] = (float)Math.Round((((W1[i] * Er1) + (W2[i] * Er2)) * 100), 2);
            Erp[i] = (float)Math.Truncate(Erp[i]);
            Risk[i] = (float)Math.Round(((Math.Sqrt((W1[i] * W1[i] * Sd1 * Sd1) + (W2[i] * W2[i] * Sd2 * Sd2) + (2 * W1[i] * W2[i] * Sd1 * Sd2 * Corr))) * 100), 2);
            TableRow tRow = new TableRow();
            riskReward.Rows.Add(tRow);
            TableCell weightCell1 = new TableCell();
            TableCell weightCell2 = new TableCell();
            TableCell riskCell = new TableCell();
            TableCell rewardCell = new TableCell();
            weightCell1.Text = (W1[i] * 100).ToString() + "%";
            weightCell2.Text = (W2[i] * 100).ToString() + "%";
            riskCell.Text = Risk[i].ToString();
            rewardCell.Text = Erp[i].ToString() + "%";
            tRow.Cells.Add(weightCell1);
            tRow.Cells.Add(weightCell2);
            tRow.Cells.Add(riskCell);
            tRow.Cells.Add(rewardCell);



        }


        // Populate series with random data
        


        for (int pointIndex = 0; pointIndex < Erp.Length; pointIndex++)
        {
            

            Chart1.Series["Series1"].Points.AddXY(Risk[pointIndex], Erp[pointIndex]);


            // Chart1.Series["Series2"].Points.AddY(random.Next(5, 75));
        }

        // Set series chart type
        Chart1.Series["Series1"].ChartType = SeriesChartType.Spline;
        ChartArea area = new ChartArea();


        Chart1.ChartAreas[0].AxisX.Minimum = 0;
        Chart1.ChartAreas[0].AxisX.Maximum = 30;

        //Chart1.Series["Series2"].ChartType = SeriesChartType.Spline;

        // Set point labels

        Chart1.Series["Series1"].IsValueShownAsLabel = true;
        Chart1.Series["Series1"]["ShowMarkerLines"] = "True";
        Chart1.ChartAreas[0].AxisX.IsMarginVisible = true;
        Chart1.Series["Series1"].MarkerStyle = MarkerStyle.Diamond;
        Chart1.ChartAreas[0].AxisX.Title = "Risk as Standard Deviation of Portfolio";
        Chart1.ChartAreas[0].AxisY.Title = "Return Expected ";
        Chart1.ChartAreas[0].AxisY2.LineWidth = 3;

        //Chart1.Series["Series2"].IsValueShownAsLabel = true;

        // Enable X axis margin

        // Chart1.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = true;

        // Enable 3D, and show data point marker lines

        //    Chart1.Series["Series1"]["ShowMarkerLines"] = "True";
        //  Chart1.Series["Series2"]["ShowMarkerLines"] = "True";
    }