コード例 #1
0
        public JsonResult UpdateOrInsert(string[] words)
        {
            var    cookie = CookiesControll.UserAuthenticationInfo();
            string word   = "";
            bool   ok;

            foreach (string wr in words)
            {
                word += $"{wr};";
            }

            word = !string.IsNullOrEmpty(word) ? word.Remove(word.Length - 1) : word;

            PhraseDTO phrase = new PhraseDTO
            {
                Frase         = word,
                DataAlteracao = DateTime.Now,
                UserId        = cookie.Name
            };

            Debug.WriteLine($"{phrase.Frase} \n {phrase.DataAlteracao} \n {phrase.Id} \n {phrase.UserId}");

            if (PhraseBLL.GetPhrase(cookie.Name).Id != "null")
            {
                ok = PhraseBLL.Update(phrase);
            }
            else
            {
                ok = PhraseBLL.Insert(phrase);
            }

            return(Json(new { ok, url = Url.Action("Configuracao", "Configuracao") }, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult Add()
        {
            var cookie      = CookiesControll.UserAuthenticationInfo();
            var genericUser = GenericUserBLL.GetUserById(cookie.Name);

            if (cookie.UserData == "Client")
            {
                if (genericUser.UserID != "null")
                {
                    ViewData["Coins"]      = TradeCoinBLL.ListAll();
                    ViewData["Operations"] = OperationBLL.ListAll();
                    ViewBag.UserId         = genericUser.UserID;
                    return(View());
                }
                else
                {
                    var quitCookie = new HttpCookie(CookiesControll.MasterCookie)
                    {
                        Expires = DateTime.Now.AddDays(-1)
                    };
                    Response.Cookies.Add(quitCookie);

                    FormsAuthentication.SignOut();

                    return(RedirectToAction("SignIn", "Login", new { area = "" }));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home", new { area = "" }));
            }
        }
コード例 #3
0
        public ActionResult Login()
        {
            var cookie = CookiesControll.UserAuthenticationInfo();

            if (cookie.Name != null)
            {
                return(RedirectToAction("Index", "Home", new { area = "" }));
            }

            return(View());
        }
コード例 #4
0
        // GET: Configuracao
        public ActionResult Configuracao()
        {
            var cookie = CookiesControll.UserAuthenticationInfo();

            if (cookie.UserData == "Client")
            {
                ViewData["Usuario"] = PhraseBLL.GetPhrase(cookie.Name);
                return(View());
            }
            else
            {
                return(RedirectToAction("Index", "Home", new { area = "" }));
            }
        }
コード例 #5
0
        public JsonResult GetHistoric(int value, bool increment)
        {
            bool has = false;
            List <HistoricDTO> temp = new List <HistoricDTO>();

            int init = (7 * value);

            init = value <= 0 ? 0 : init;
            int end = 7;

            temp = HistoricBLL.ListAll(CookiesControll.UserAuthenticationInfo().Name, init, end);
            has  = temp.Count > 0 ? true : false;

            return(Json(new { has, temp }, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
        public JsonResult CreateTrade(TradeDTO trade)
        {
            var coin        = TradeCoinBLL.ListAll();
            var type        = OperationBLL.ListAll();
            var cookie_info = CookiesControll.UserAuthenticationInfo().Name;

            trade.Tipo   = type.Where(t => t.Id == trade.Tipo).FirstOrDefault().Tipo;
            trade.UserId = cookie_info;

            if (!string.IsNullOrEmpty(trade.MoedaCompra) && !string.IsNullOrWhiteSpace(trade.MoedaCompra))
            {
                trade.MoedaCompra = coin.Where(c => c.Id == trade.MoedaCompra).FirstOrDefault().Sigla;
            }

            if (!string.IsNullOrEmpty(trade.MoedaVenda) && !string.IsNullOrWhiteSpace(trade.MoedaVenda))
            {
                trade.MoedaVenda = coin.Where(c => c.Id == trade.MoedaVenda).FirstOrDefault().Sigla;
            }

            if (!string.IsNullOrEmpty(trade.MoedaTaxa) && !string.IsNullOrWhiteSpace(trade.MoedaTaxa))
            {
                trade.MoedaTaxa = coin.Where(c => c.Id == trade.MoedaTaxa).FirstOrDefault().Sigla;
            }

            bool inserts_ok = false;

            if (TradeBLL.RegisterUser(trade))
            {
                inserts_ok = true;

                HistoricDTO hist = new HistoricDTO
                {
                    Data      = DateTime.Now.Date,
                    UserId    = cookie_info,
                    Descricao = $"Adicionado uma nova {trade.Tipo}"
                };

                inserts_ok = HistoricBLL.RegisterHistoric(hist);
            }

            var url = Url.Action("Trocas", "Trocas");

            return(Json(new { insert = inserts_ok, url }, JsonRequestBehavior.AllowGet));
        }
コード例 #7
0
        public JsonResult GetTrades(int value, bool increment)
        {
            bool            has  = false;
            List <TradeDTO> temp = new List <TradeDTO>();

            int init = (max_trade * value);

            init = value <= 0 ? 0 : init;
            int end = max_trade;

            temp = TradeBLL.ListAllByIdLimited(init, end, CookiesControll.UserAuthenticationInfo().Name);

            foreach (var item in temp)
            {
                item.ValorVenda  = FillWithZeros(item.ValorVenda);
                item.ValorCompra = FillWithZeros(item.ValorCompra);
                item.ValorTaxa   = FillWithZeros(item.ValorTaxa);
            }

            has = temp.Count > 0 ? true : false;

            return(Json(new { has, temp }, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
        public JsonResult Remove(TradeDTO[] trade)
        {
            bool   deleted = false;
            string text    = "";

            if (TradeBLL.Remove(trade))
            {
                deleted = true;
                text    = trade.Length > 1 ? "Removidos" : "Removido";
                text   += $" {trade.Length} ";
                text   += trade.Length > 1 ? "transações" : "transação";

                HistoricDTO hist = new HistoricDTO
                {
                    Data      = DateTime.Now.Date,
                    UserId    = CookiesControll.UserAuthenticationInfo().Name,
                    Descricao = text
                };

                deleted = HistoricBLL.RegisterHistoric(hist);
            }

            return(Json(new { deleted, url = Url.Action("Trocas", "Trocas") }, JsonRequestBehavior.AllowGet));
        }
コード例 #9
0
        public ActionResult Trocas()
        {
            var cookie = CookiesControll.UserAuthenticationInfo();

            if (cookie.UserData == "Client")
            {
                var list = TradeBLL.ListAllByIdLimited(0, max_trade, cookie.Name);

                foreach (var item in list)
                {
                    item.ValorVenda  = FillWithZeros(item.ValorVenda);
                    item.ValorCompra = FillWithZeros(item.ValorCompra);
                    item.ValorTaxa   = FillWithZeros(item.ValorTaxa);
                }

                ViewData["Trocas"]    = list;
                ViewData["Historico"] = HistoricBLL.ListAll(cookie.Name, 0, 7);
                return(View());
            }
            else
            {
                return(RedirectToAction("Index", "Home", new { area = "" }));
            }
        }
コード例 #10
0
 public JsonResult UpdatePassword(string pass)
 {
     Debug.WriteLine($"{pass} Senha");
     return(Json(UserBLL.UpdatePassword(CookiesControll.UserAuthenticationInfo().Name, pass), JsonRequestBehavior.AllowGet));
 }
コード例 #11
0
 public JsonResult GetPhrase()
 {
     return(Json(PhraseBLL.GetPhrase(CookiesControll.UserAuthenticationInfo().Name), JsonRequestBehavior.AllowGet));
 }
コード例 #12
0
 public JsonResult GetCurPass()
 {
     return(Json(UserBLL.GetUserById(CookiesControll.UserAuthenticationInfo().Name), JsonRequestBehavior.AllowGet));
 }
コード例 #13
0
 public JsonResult UserId()
 {
     return(Json(CookiesControll.UserAuthenticationInfo().Name, JsonRequestBehavior.AllowGet));
 }