예제 #1
0
        public async Task <ActionResult> Add(StockCodeModel stockcode) // Tạo mã co phieu
        {
            LoadInit();
            if (ModelState.IsValid)
            {
                using (dbcungphim = new db_cungphim_FrontEnd())
                {
                    if (dbcungphim.StockCodes.Any(t => t.Code == stockcode.Code))
                    {
                        ModelState.AddModelError("", "Đã tồn tại mã cổ phiếu này trong thệ thống");
                    }
                    else
                    {
                        dbcungphim.StockCodes.Add(new StockCode {
                            Code = stockcode.Code.ToUpper(), IndexName = stockcode.IndexName, LongName = stockcode.LongName, MarketType = stockcode.MarketType, ShortName = stockcode.ShortName
                        });
                        await dbcungphim.SaveChangesAsync();

                        return(View(stockcode));
                    }

                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                return(View());
            }
        }
예제 #2
0
        public async Task <ActionResult> Detail(int tickerid, string stockCode) // list user
        {
            using (dbcungphim = new db_cungphim_FrontEnd())
            {
                var hotTicker = await dbcungphim.TickerHots.FindAsync(tickerid);

                if (hotTicker != null)
                {
                    if (hotTicker.THName.ToUpper() != stockCode.ToUpper())
                    {
                        hotTicker.THName = stockCode;
                        try
                        {
                            dbcungphim.Entry(hotTicker).State = EntityState.Modified;
                            await dbcungphim.SaveChangesAsync();
                        }
                        catch (Exception)
                        {
                            //throw;
                        }
                    }
                }
            }
            return(RedirectToAction(""));
        }
예제 #3
0
        public async Task <ActionResult> DeleteConfirmed(long postid)
        {
            using (dbcungphim = new db_cungphim_FrontEnd())
            {
                var url = Request.Url.Query.Replace("?postid=" + postid + "&returnUrl=", "");
                // remove notification
                var notifications = await dbcungphim.NotificationMesseges.Where(n => n.PostId == postid).ToListAsync();

                dbcungphim.NotificationMesseges.RemoveRange(notifications);
                //
                // remove  stockRelate
                var stockRelates = await dbcungphim.StockRelates.Where(n => n.PostId == postid).ToListAsync();

                dbcungphim.StockRelates.RemoveRange(stockRelates);
                //
                // remove  stockRelate
                var comments = await dbcungphim.PostComments.Where(n => n.PostedBy == postid).ToListAsync();

                dbcungphim.PostComments.RemoveRange(comments);
                //

                Post post = await dbcungphim.Posts.FindAsync(postid);

                dbcungphim.Posts.Remove(post);
                await dbcungphim.SaveChangesAsync();

                return(RedirectToLocal(url));
            }
        }
예제 #4
0
        public async Task <ActionResult> Detail(StockCodeModel stockcode) // list user
        {
            LoadInit();
            if (ModelState.IsValid)
            {
                using (dbcungphim = new db_cungphim_FrontEnd())
                {
                    //var url = Request.Url.Query.Replace("?stockid=" + userid + "&returnUrl=", "");
                    var stockCode = await dbcungphim.StockCodes.FindAsync(stockcode.Id);

                    stockCode.Code       = stockcode.Code;
                    stockCode.ShortName  = stockcode.ShortName;
                    stockCode.LongName   = stockcode.LongName;
                    stockCode.MarketType = stockcode.MarketType;
                    stockCode.IndexName  = stockcode.IndexName;
                    try
                    {
                        dbcungphim.Entry(stockCode).State = EntityState.Modified;
                        await dbcungphim.SaveChangesAsync();

                        return(RedirectToAction(""));
                    }
                    catch (Exception)
                    {
                        return(View());
                    }
                }
            }
            else
            {
                return(View());
            }
        }
예제 #5
0
        public async Task <ActionResult> DeleteConfirmed(long commentid, long postid)
        {
            using (dbcungphim = new db_cungphim_FrontEnd())
            {
                // remove notification
                try
                {
                    PostComment postComment = await dbcungphim.PostComments.FindAsync(commentid);

                    Post post = await dbcungphim.Posts.FindAsync(postid);

                    if (post.SumReply > 0)
                    {
                        post.SumReply -= 1;
                        dbcungphim.Entry(post).State = EntityState.Modified;
                    }
                    dbcungphim.PostComments.Remove(postComment);
                    await dbcungphim.SaveChangesAsync();
                }
                catch (Exception)
                {
                    //
                }

                return(RedirectToAction(""));
            }
        }
예제 #6
0
        public async Task <ActionResult> Detail(long pinid, string stockCode) // list user
        {
            using (dbcungphim = new db_cungphim_FrontEnd())
            {
                var pin = await dbcungphim.PinStocks.FindAsync(pinid);

                if (pin != null)
                {
                    if (pin.StockCodePin.ToUpper() != stockCode.ToUpper())
                    {
                        pin.StockCodePin = stockCode;
                        try
                        {
                            dbcungphim.Entry(pin).State = EntityState.Modified;
                            await dbcungphim.SaveChangesAsync();
                        }
                        catch (Exception)
                        {
                            //throw;
                        }
                    }
                }
            }
            return(RedirectToAction(""));
        }
예제 #7
0
        public async Task <ActionResult> Update(Boolean?brokerVIP, int userid, int characterLimitInput, bool?disableUser)
        {
            var url = Request.Url.Query.Replace("?userid=" + userid + "&returnUrl=", "");

            using (dbcungphim = new db_cungphim_FrontEnd())
            {
                var user = await dbcungphim.UserLogins.FindAsync(userid);

                if (user != null)
                {
                    if (user.BrokerVIP != brokerVIP)
                    {
                        user.BrokerVIP = brokerVIP;
                        try
                        {
                            dbcungphim.Entry(user).State = EntityState.Modified;
                            await dbcungphim.SaveChangesAsync();
                        }
                        catch (Exception)
                        {
                            //throw;
                        }
                    }
                    if (user.CharacterLimit != characterLimitInput)
                    {
                        user.CharacterLimit = characterLimitInput > 12000 ? 12000 : characterLimitInput;
                        try
                        {
                            dbcungphim.Entry(user).State = EntityState.Modified;
                            await dbcungphim.SaveChangesAsync();
                        }
                        catch (Exception)
                        {
                            //throw;
                        }
                    }
                    if (user.DisableUser != disableUser)
                    {
                        user.DisableUser = disableUser;
                        try
                        {
                            dbcungphim.Entry(user).State = EntityState.Modified;
                            await dbcungphim.SaveChangesAsync();
                        }
                        catch (Exception)
                        {
                            //throw;
                        }
                    }
                }
            }


            return(Redirect(url));
        }
예제 #8
0
        public async Task <ActionResult> Delete(int tickerid) // list user
        {
            using (dbcungphim = new db_cungphim_FrontEnd())
            {
                var hotTicker = await dbcungphim.TickerHots.FindAsync(tickerid);

                if (hotTicker != null)
                {
                    try
                    {
                        dbcungphim.TickerHots.Remove(hotTicker);
                        await dbcungphim.SaveChangesAsync();
                    }
                    catch (Exception)
                    {
                        //throw;
                    }
                }
            }
            return(RedirectToAction(""));
        }
예제 #9
0
        public async Task <ActionResult> Delete(long pinid) // list user
        {
            using (dbcungphim = new db_cungphim_FrontEnd())
            {
                var pin = await dbcungphim.PinStocks.FindAsync(pinid);

                if (pin != null)
                {
                    try
                    {
                        dbcungphim.PinStocks.Remove(pin);
                        await dbcungphim.SaveChangesAsync();
                    }
                    catch (Exception)
                    {
                        //throw;
                    }
                }
            }
            return(RedirectToAction(""));
        }
예제 #10
0
        public async Task <ActionResult> Add(TickerHotModel tickerHot) // Tạo mã nóng
        {
            if (ModelState.IsValid)
            {
                using (dbcungphim = new db_cungphim_FrontEnd())
                {
                    if (dbcungphim.TickerHots.Any(t => t.THName.ToUpper() == tickerHot.THName.ToUpper()))
                    {
                        ModelState.AddModelError("", "Đã tồn tại mã cổ phiếu này trong thệ thống");
                    }
                    else
                    {
                        dbcungphim.TickerHots.Add(new TickerHot {
                            THName = tickerHot.THName.ToUpper()
                        });
                        await dbcungphim.SaveChangesAsync();

                        return(RedirectToAction("Index"));
                    }
                }
            }
            return(View(tickerHot));
        }
예제 #11
0
        public async Task <ActionResult> Add(PinModel pinModel) // Tạo mã nóng
        {
            if (ModelState.IsValid)
            {
                using (dbcungphim = new db_cungphim_FrontEnd())
                {
                    if (dbcungphim.PinStocks.Any(t => t.StockCodePin == pinModel.StockName && t.PostId == pinModel.PostId))
                    {
                        ModelState.AddModelError("", "Đã tồn tại PIN này trong thệ thống");
                    }
                    else
                    {
                        dbcungphim.PinStocks.Add(new PinStock {
                            StockCodePin = pinModel.StockName.ToUpper(), PostId = pinModel.PostId, CreatedDate = DateTime.Now
                        });
                        await dbcungphim.SaveChangesAsync();

                        return(RedirectToAction("Index"));
                    }
                }
            }
            return(View(pinModel));
        }
예제 #12
0
        public async Task <ActionResult> Update(long postid, int?sumLike, string StockCode, string messegeInput, byte?priority)
        {
            var url = Request.Url.Query.Replace("?postid=" + postid + "&returnUrl=", "");

            using (dbcungphim = new db_cungphim_FrontEnd())
            {
                Post post = await dbcungphim.Posts.FindAsync(postid);

                if (post != null)
                {
                    if (post.SumLike != sumLike)
                    {
                        try
                        {
                            //post.StockPrimary = StockCode;
                            post.SumLike = (sumLike == null ? 0 : (int)sumLike);
                            dbcungphim.Entry(post).State = EntityState.Modified;
                            await dbcungphim.SaveChangesAsync();
                        }
                        catch (Exception)
                        {
                            //throw;
                        }
                    }
                    if (!post.StockPrimary.Equals(StockCode))
                    {
                        try
                        {
                            //post.StockPrimary = StockCode;
                            post.StockPrimary            = (string.IsNullOrEmpty(StockCode) ? "" : StockCode);
                            dbcungphim.Entry(post).State = EntityState.Modified;
                            await dbcungphim.SaveChangesAsync();
                        }
                        catch (Exception)
                        {
                            //throw;
                        }
                    }
                    if (!post.Message.Equals(messegeInput))
                    {
                        try
                        {
                            post.Message = string.IsNullOrEmpty(messegeInput) ? "" : messegeInput;
                            dbcungphim.Entry(post).State = EntityState.Modified;
                            await dbcungphim.SaveChangesAsync();
                        }
                        catch (Exception)
                        {
                            //throw;
                        }
                    }
                    if (!post.Priority.Equals(priority))
                    {
                        try
                        {
                            post.Priority = priority;
                            dbcungphim.Entry(post).State = EntityState.Modified;
                            await dbcungphim.SaveChangesAsync();
                        }
                        catch (Exception)
                        {
                            //throw;
                        }
                    }
                }
            }
            return(RedirectToLocal(url));
        }