示例#1
0
        public async Task Post([FromBody] FundAllocation value)
        {
            using (PersonalContext pc = new PersonalContext())
            {
                FundAllocation fa = (from p in pc.FundAllocation where p.Symbol == value.Symbol select p).FirstOrDefault();

                if (fa != null)
                {
                    resetFA(ref fa, value);
                    pc.Update(fa);
                }
                else
                {
                    fa = new FundAllocation();
                    resetFA(ref fa, value);
                    pc.FundAllocation.Add(fa);
                }
                try
                {
                    await pc.SaveChangesAsync();
                }
                catch (Exception ex)
                {
                    string s = ex.Message;
                }
            }
        }
示例#2
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     ConnectionString();
     personalDb  = new PersonalContext("PersonalContext").SeedIfEmpty();
     northwindDb = new NorthwindContext();
     viewModel   = new ViewModel(personalDb, northwindDb);
     DataContext = viewModel;
     AccessDatabase();
 }
示例#3
0
        public void Delete(string id)
        {
            PersonalContext pc = new PersonalContext();

            FundAllocation fa = (from p in pc.FundAllocation where p.Symbol == id select p).FirstOrDefault();

            if (fa != null)
            {
                pc.FundAllocation.Remove(fa);
                pc.SaveChanges();
            }
        }
示例#4
0
        public IEnumerable <FundsValue> Get()
        {
            PersonalContext pc = new PersonalContext();

            //return from c in pc.FundsValue select c;
            return(from a in pc.FundAllocation
                   join cc in pc.FundsValue on a.Symbol equals cc.FundName into ac
                   from aci in ac.DefaultIfEmpty()
                   select new FundsValue {
                FvId = aci.FvId, FundName = a.Symbol, Value = aci.Value, CyberAccountId = aci.CyberAccountId
            });
        }
示例#5
0
        public IEnumerable <IPoint> GetSummary()
        {
            PersonalContext pc = new PersonalContext();
            //var vRec = (from v in pc.FundsValue join a in pc.FundAllocation on v.FundName equals a.Symbol
            //            select new { cash = (decimal)v.Value * (decimal)a.Cash, fixedIncome = (decimal)v.Value * (decimal)a.FixedIncome,
            //                nonUsequity = (decimal)v.Value * (decimal)a.Usequity, other = (decimal)v.Value * (decimal)a.Other} );

            string specifier = "0.00";

            var vCash = ((from v in pc.FundsValue
                          join a in pc.FundAllocation on v.FundName equals a.Symbol
                          select(decimal) v.Value *(decimal)a.Cash).Sum() / 100).ToString(specifier, CultureInfo.InvariantCulture);
            var vFixedIncome = ((from v in pc.FundsValue
                                 join a in pc.FundAllocation on v.FundName equals a.Symbol
                                 select(decimal) v.Value *(decimal)a.FixedIncome).Sum() / 100).ToString(specifier, CultureInfo.InvariantCulture);;
            var vUs = ((from v in pc.FundsValue
                        join a in pc.FundAllocation on v.FundName equals a.Symbol
                        select(decimal) v.Value *(decimal)a.Usequity).Sum() / 100).ToString(specifier, CultureInfo.InvariantCulture);
            var vNUs = ((from v in pc.FundsValue
                         join a in pc.FundAllocation on v.FundName equals a.Symbol
                         select(decimal) v.Value *(decimal)a.NonUsequity).Sum() / 100).ToString(specifier, CultureInfo.InvariantCulture);;
            var vOther = ((from v in pc.FundsValue
                           join a in pc.FundAllocation on v.FundName equals a.Symbol
                           select(decimal) v.Value *(decimal)a.Other
                           ).Sum() / 100).ToString(specifier, CultureInfo.InvariantCulture);

            IPoint[] points = new IPoint[5];
            points[0] = new IPoint()
            {
                type = "Cash", amount = Convert.ToDecimal(vCash)
            };
            points[1] = new IPoint()
            {
                type = "FixedIncome", amount = Convert.ToDecimal(vFixedIncome)
            };
            points[2] = new IPoint()
            {
                type = "USEquity", amount = Convert.ToDecimal(vUs)
            };
            points[3] = new IPoint()
            {
                type = "NonUSEquity", amount = Convert.ToDecimal(vNUs)
            };
            points[4] = new IPoint()
            {
                type = "Other", amount = Convert.ToDecimal(vOther)
            };
            return(points);
        }
示例#6
0
 public FundsValue Get(int id)
 {
     if (id != 0)
     {
         PersonalContext pc = new PersonalContext();
         return((from c in pc.FundsValue where c.FvId == id select c).FirstOrDefault());
     }
     else
     {
         FundsValue fv = new FundsValue();
         fv.FundName = "";
         //fv.Value = "Value";
         fv.CyberAccountId = "";
         // fv.Date = "Date";
         return(fv);
     }
 }
示例#7
0
        public ActionResult Edit(UsuarioView view)
        {
            if (ModelState.IsValid)
            {
                var db2     = new PersonalContext();
                var oldUser = db2.Usuarios.Find(view.Usuario.UserId);
                db2.Dispose();

                if (view.Foto != null)
                {
                    var pic = Uteis.UploadPhoto(view.Foto);
                    if (!string.IsNullOrEmpty(pic))
                    {
                        view.Usuario.Photo = string.Format("~/Content/Fotos/{0}", pic);
                    }
                }
                else
                {
                    view.Usuario.Photo = oldUser.Photo;
                }


                db.Entry(view.Usuario).State = EntityState.Modified;

                try
                {
                    if (oldUser != null && oldUser.UserName != view.Usuario.UserName)
                    {
                        Uteis.ChangeEmailUserAsp(oldUser.UserName, view.Usuario.UserName);
                    }
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, ex.Message);
                    return(View(view));
                }

                return(RedirectToAction("Index"));
            }
            return(View(view.Usuario));
        }
        public IHttpActionResult PutUsuario(int id, Usuario usuario)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != usuario.UserId)
            {
                return(BadRequest());
            }

            var db2     = new PersonalContext();
            var oldUser = db2.Usuarios.Find(usuario.UserId);

            db2.Dispose();

            db.Entry(usuario).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
                if (oldUser != null && oldUser.UserName != usuario.UserName)
                {
                    Uteis.ChangeEmailUserAsp(oldUser.UserName, usuario.UserName);
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UsuarioExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(this.Ok(usuario));
        }
示例#9
0
        static void Main(string[] args)
        {
            using (var ctx = new PersonalContext())
            {
                var location1 = ctx.Locations.FirstOrDefault(x => x.City.Equals("Craiova"));
                if (location1 != null)
                {
                    location1.PostalCode = "123456";
                    ctx.Locations.AddOrUpdate(location1);
                }

                ctx.SaveChanges();

                var location2 = ctx.Locations.FirstOrDefault(x => x.City.Equals("Bucuresti"));
                if (location2 != null)
                {
                    ctx.Locations.Remove(location2);
                }

                ctx.SaveChanges();
            }
        }
示例#10
0
        static void Main(string[] args)
        {
            using (var ctx = new PersonalContext())
            {

                var location1 = ctx.Locations.FirstOrDefault(x => x.City.Equals("Craiova"));
                if (location1 != null)
                {
                    location1.PostalCode = "123456";
                    ctx.Locations.AddOrUpdate(location1);
                }

                ctx.SaveChanges();

                var location2 = ctx.Locations.FirstOrDefault(x => x.City.Equals("Bucuresti"));
                if (location2 != null)
                {
                    ctx.Locations.Remove(location2);
                }

                ctx.SaveChanges();
            }
        }
示例#11
0
        public void Post([FromBody] FundsValue value)
        {
            PersonalContext pc  = new PersonalContext();
            var             rec = (from c in pc.FundsValue where c.FundName == value.FundName && c.CyberAccountId == value.CyberAccountId &&
                                   c.Date > DateTime.Now.AddDays(-10) select c).FirstOrDefault();

            if (rec != null)
            {
                rec.Value          = value.Value;
                rec.CyberAccountId = value.CyberAccountId;
                rec.Date           = DateTime.Now;
                pc.Update(rec);
            }
            else
            {
                FundsValue fv = new FundsValue();
                fv.FundName       = value.FundName;
                fv.Value          = value.Value;
                fv.CyberAccountId = value.CyberAccountId;
                fv.Date           = DateTime.Now;
                pc.FundsValue.Add(fv);
            }
            pc.SaveChanges();
        }
 public DepartmentRepository(PersonalContext context) : base(context)
 {
 }
示例#13
0
 public PostsController(PersonalContext context, UserManager <ApplicationUser> userManager, IHostingEnvironment env)
 {
     _context     = context;
     _userManager = userManager;
     _env         = env;
 }
 public tokenController(IConfiguration config, PersonalContext personalContext)
 {
     _config          = config;
     _personalContext = personalContext ?? throw new ArgumentNullException(nameof(personalContext));
 }
示例#15
0
 public GetPersonsHandler(ILogger <GetPersonsHandler> logger, PersonalContext context)
 {
     _logger  = logger;
     _context = context;
 }
示例#16
0
 public DataBaseService()
 {
     _context = new PersonalContext();
 }
示例#17
0
        public void Put(string id, FundAllocation value)
        {
            PersonalContext pc = new PersonalContext();

            FundAllocation fa = (from p in pc.FundAllocation where p.Symbol == id select p).FirstOrDefault();
        }
 public PersonalRepository(PersonalContext context) : base(context)
 {
 }
 public PayTypeController(PersonalContext personalContext, IHttpContextAccessor accessor)
 {
     _personalContext     = personalContext ?? throw new ArgumentNullException(nameof(personalContext));
     _httpContextAccessor = accessor ?? throw new ArgumentNullException(nameof(accessor));
 }
示例#20
0
 public CreatePersonHandler(IValidator <CreatePersonRequest> vadiator, PersonalContext context)
 {
     _validator = vadiator;
     _context   = context;
 }
示例#21
0
        public IEnumerable <FundAllocation> Get()
        {
            PersonalContext pc = new PersonalContext();

            return(from c in pc.FundAllocation select c);
        }
 public ReportController(PersonalContext personalContext, IHttpContextAccessor accessor, IMapper mapper)
 {
     _personalContext     = personalContext ?? throw new ArgumentNullException(nameof(personalContext));
     _httpContextAccessor = accessor ?? throw new ArgumentNullException(nameof(accessor));
     _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
 }
示例#23
0
        public FundAllocation Get(string id)
        {
            PersonalContext pc = new PersonalContext();

            return((from c in pc.FundAllocation where c.Symbol == id select c).FirstOrDefault());
        }
示例#24
0
 public ViewModel(PersonalContext personalDb, NorthwindContext northwindDb)
 {
 }
示例#25
0
 public IRepoServices(PersonalContext context, ILogger <IRepoServices> logger)
 {
     _context = context;
     _logger  = logger;
 }