コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            TotalReturns totalReturns = db.totalreturns.Find(id);

            db.totalreturns.Remove(totalReturns);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        // GET: TotalReturns/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TotalReturns totalReturns = db.totalreturns.Find(id);

            if (totalReturns == null)
            {
                return(HttpNotFound());
            }
            return(View(totalReturns));
        }
コード例 #3
0
        public async System.Threading.Tasks.Task <ActionResult> CustLotReturn()
        {
            TotalReturns         tttlR = new TotalReturns();
            ApplicationDbContext ab    = new ApplicationDbContext();
            var ss = ab.Users.ToList();
            List <ApplicationUser> ls = new List <ApplicationUser>();
            var dd = db.totalreturns.ToList();

            foreach (var item in ss)
            {
                foreach (var item1 in dd)
                {
                    if (item1.totalReturns > 50 && item.businessname == item1.Business)
                    {
                        ls.Add(item);

                        if (item1.Status == "False")
                        {
                            var         from    = "*****@*****.**";
                            var         pass    = "******";
                            MailMessage message = new MailMessage();
                            SmtpClient  client  = new SmtpClient("smtp.gmail.com", 587);
                            client.UseDefaultCredentials = false;
                            client.Credentials           = new System.Net.NetworkCredential(from, pass);
                            client.EnableSsl             = true;


                            var mail = new MailMessage(from, item.Email);
                            mail.Subject    = "Warning regarding exceeding returns";
                            mail.Body       = "PLEASE NOTE: You have been returning excess stock back to Elenas Delicacies for just over a short period of time. <br/> You are therefore warned that shall you continue doing this, we will have to remove you from the system and cancel our business deal. <br/> We will contact you in order to discuess this issue further. Also you will not get another warning and the only next step will be to remove you from the system as mentioned above. <br/><br/> Regards <br/>Elenas Delicacies";
                            mail.IsBodyHtml = true;
                            item1.Status    = "True";
                            db.SaveChanges();
                            client.Send(mail);
                        }
                    }
                }
            }



            return(View(ls));
        }
コード例 #4
0
        TotalReturns GetTotalReturnsFor(Index security)
        {
            var result = new TotalReturns(security);

            using (var session = _sessionFactory.GetSession())
            {
                var service = session.CreateService();

                var priceRequest = service.CreateRequest(RequestType.HistoricalDataRequest);

                priceRequest.Append("securities", security.BloombergName);

                priceRequest.Append("fields", "PX_LAST");
                priceRequest.Set("startDate", new YearMonth(2012, 1).AsDateTime().ToBBDateTimeString());
                priceRequest.Set("endDate", new YearMonth(2013, 12).AsDateTime().ToBBDateTimeString());
                priceRequest.Set("periodicitySelection", "MONTHLY");
                priceRequest.Set("currency", security.CurrencyCode);

                session.ProcessRequest(priceRequest, @event => @event.ForEachFieldData(fdi =>
                {
                    var date = fdi.GetElementAsDate("date").ToSystemDateTime();
                    var lastPrice = fdi.GetElementAsFloat64("PX_LAST");

                    result.Add(date, Convert.ToDecimal(lastPrice));
                }));

                if (security.UseUnderlyingPriceForReturn)
                { // Calculate Return manually
                    foreach (var index in result)
                    {
                        var lastValue = index.GetLastValue();
                        if (index.Value == null || lastValue == null || lastValue == 0m) continue;
                        index.Return = Percent.CreateFromDecimalNotation((index.Value.Value / lastValue) - 1);
                    }
                }
                else
                { // Retrieve Return from Bloomberg
                    foreach (var index in result)
                    {
                        if (index._previous == null) continue;

                        // =BDP("SPX INDEX", "CUST_TRR_RETURN_HOLDING_PER", "CUST_TRR_START_DT,CUST_TRR_END_DT,CUST_TRR_CRNCY", "20121031,20121130,USD")
                        var start = index._previous.DateTime;
                        var end = index.DateTime;

                        var returnRequest = service.CreateRequest(RequestType.ReferenceDataRequest);
                        returnRequest.Append("securities", security.BloombergName);
                        returnRequest.Append("fields", "CUST_TRR_RETURN_HOLDING_PER");
                        returnRequest.AddOverride("CUST_TRR_START_DT", start.ToBBDateTimeString());
                        returnRequest.AddOverride("CUST_TRR_END_DT", end.ToBBDateTimeString());
                        returnRequest.AddOverride("CUST_TRR_CRNCY", security.CurrencyCode);

                        session.ProcessRequest(returnRequest, @event => @event.ForEachFieldData(fdi =>
                        {
                            if (fdi.HasElement("CUST_TRR_RETURN_HOLDING_PER"))
                            {
                                var rtn = fdi.GetElementAsFloat64("CUST_TRR_RETURN_HOLDING_PER");
                                index.Return = Percent.CreateFromPercentageNotation(Convert.ToDecimal(rtn));
                            }
                        }));
                    }
                }
            }

            return result;
        }