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)); }
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("")); }
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()); } }
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("")); } }
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("")); }
public async Task <ActionResult> Edit([Bind(Include = "PostId,Message,PostedBy,PostedDate,ChartImageURL,NhanDinh,Vir,StockPrimary,ChartYN,SumLike,SumReply")] Post post) { if (ModelState.IsValid) { db.Entry(post).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.PostedBy = new SelectList(db.UserLogins, "Id", "KeyLogin", post.PostedBy); return(View(post)); }
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)); }