示例#1
0
        public ActionResult AddPortofolio(PortofolioViewModel model)
        {
            List <Category> list = db.Categories.ToList();

            ViewBag.CategoryList = new SelectList(list, "Id_Category", "Category_Name");

            var file = model.ImageUpload;

            byte[] imagebyte = null;

            if (file != null)
            {
                string filename  = Path.GetFileNameWithoutExtension(file.FileName);
                string extension = Path.GetExtension(file.FileName);

                filename = filename + DateTime.Now.ToString("yymmssff") + extension;

                file.SaveAs(Server.MapPath("/Images/gallery/" + filename));
                BinaryReader reader = new BinaryReader(file.InputStream);
                imagebyte = reader.ReadBytes(file.ContentLength);
                Portofolio porto = new Portofolio();

                porto.Title      = model.Title;
                porto.Category   = model.Category;
                porto.ImageTitle = filename;
                porto.ImageByte  = imagebyte;
                porto.ImagePath  = "/Images/gallery/" + filename;

                db.Portofolios.Add(porto);
                db.SaveChanges();
            }
            var response = true;

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Portofolio portofolio = db.Portofolios.Find(id);

            db.Portofolios.Remove(portofolio);
            db.SaveChanges();
            return(RedirectToAction("AdminIndex"));
        }
示例#3
0
        // GET: Portofolios/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Portofolio portofolio = db.Portofolios.Find(id);

            if (portofolio == null)
            {
                return(HttpNotFound());
            }
            return(View(portofolio));
        }
示例#4
0
        public ActionResult Create(Portofolio portofolio, HttpPostedFileBase upload)
        {
            if (ModelState.IsValid)
            {
                string path = Path.Combine(Server.MapPath("~/Image/"), upload.FileName);
                upload.SaveAs(path);
                portofolio.Prt_img = upload.FileName;
                db.Portofolios.Add(portofolio);
                db.SaveChanges();
                return(RedirectToAction("AdminIndex"));
            }

            return(View(portofolio));
        }
示例#5
0
        public ActionResult UpdatePortofolio(PortofolioViewModel model)
        {
            if (model.Id_Portofolio > 0)
            {
                Portofolio porto = new Portofolio();

                porto = db.Portofolios.SingleOrDefault(x => x.Id_Portofolio == model.Id_Portofolio);

                porto.Title    = model.Title;
                porto.Category = model.Category;

                db.SaveChanges();
            }

            var response = true;

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
示例#6
0
        public ActionResult Edit([Bind(Include = "Prt_Id,Prt_Name,Prt_Date,Prt_Client,Prt_Categry,Prt_img")] Portofolio portofolio, HttpPostedFileBase upload)
        {
            string oldPath = Path.Combine(Server.MapPath("~/Image/") + portofolio.Prt_img);

            if (ModelState.IsValid)
            {
                if (upload != null)
                {
                    //    System.IO.File.Delete(oldPath);
                    string path = Path.Combine(Server.MapPath("~/Image/"), upload.FileName);
                    upload.SaveAs(path);
                    portofolio.Prt_img = upload.FileName;
                }
                db.Entry(portofolio).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("AdminIndex"));
            }
            return(View(portofolio));
        }
示例#7
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl      = returnUrl ?? Url.Content("~/");
            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = Input.Email, Email = Input.Email
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    Portofolio portofolio = new Portofolio();
                    portofolio.UserId = user.Id;
                    Balance balance = new Balance();
                    balance.Amount = 100;
                    var currency = currencyService.ReadCurrency(2);
                    balance.Currency    = currency;
                    balance.Portofolio  = portofolio;
                    portofolio.Balances = new List <Balance>();
                    portofolio.Balances.Add(balance);
                    db.Portoflios.Add(portofolio);
                    db.Balances.Add(balance);
                    await db.SaveChangesAsync();



                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { area = "Identity", userId = user.Id, code = code, returnUrl = returnUrl },
                        protocol: Request.Scheme);

                    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    if (_userManager.Options.SignIn.RequireConfirmedAccount)
                    {
                        return(RedirectToPage("RegisterConfirmation", new { email = Input.Email, returnUrl = returnUrl }));
                    }
                    else
                    {
                        await _signInManager.SignInAsync(user, isPersistent : false);

                        return(LocalRedirect(returnUrl));
                    }
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
        public void Initialise(System.Collections.Generic.List<StockClasses.StockSerie> stockSeries, Portofolio.StockPortofolio portfolio, StockDictionary stockDictionary)
        {
            this.Series = stockSeries;
             this.Portfolio = portfolio;
             this.StockDictionary = stockDictionary;

             this.availableLiquidity = portfolio.AvailableLiquitidity;

             this.Positions = new List<StockPosition>();
        }