public object getTrangCaNhanFlow(int id_user) { string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } int status = 0; string Id = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataTable dt_group = new DataTable(); DataTable dt_user = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = ""; DataTable dt_token = new DataTable(); try { using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { dt = cnn.CreateDataTable(@" select distinct ID_CANHAN,u.ID_USER,AnhBia,UserName,AVATAR,TieuSu from TBL_TRANGCANHAN as cn, TBL_Account as u where cn.ID_USER=u.ID_USER and u.ID_USER="******"ID_CANHAN"], Id_user = g["ID_USER"], hinhanhbia = g["AnhBia"], tieusu = g["TieuSu"], anhbia = LiteController.genLinkImage_Post(_config.LinkAPI, g["AnhBia"]), //media = g["TYPEPOST"], //imgmedia = $"{link}/UploadedFiles/{g["TYPEPOST"]}", //id_user = r["ID_USER"], user_name = g["UserName"], hinhanh = g["AVATAR"], Avatar = LiteController.genLinkAvatar(_config.LinkAPI, g["AVATAR"]), }; return(JsonResultCommon.ThanhCong(data)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
public object GetLuuTruKhenThuongUser() { { int status = 0; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = ""; DataTable dt_token = new DataTable(); try { //Conds.Add("email", Email); //Conds.Add("password", Pass); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { string sql = @" select bd.ID_BAIDANG,bd.TIEUDE,bd.NOIDUNG_BAIDANG,bd.CreatedDate,bd.CreatedBy,kt.TIEUDE AS TIEUDE_KT,kt.LINK_ICON,u.UserName,u.AVATAR from TBL_BAIDANG as bd,TBL_KHENTHUONG as kt,TBL_Account as u where bd.ID_KHENTHUONG is not null and bd.ID_KHENTHUONG=kt.ID_KHENTHUONG and bd.CreatedBy=u.ID_USER "; dt = cnn.CreateDataTable(sql, Conds); dr = dt.Select(); } var data = from r in dr.AsEnumerable() select new { Id_BaiDang = r["ID_BAIDANG"], tieude_baidang = r["TIEUDE"], noidungbaidang = r["NOIDUNG_BAIDANG"], createdate = r["CreatedDate"], createby = r["CreatedBy"], tieude_kt = r["TIEUDE_KT"], icon_kt = r["LINK_ICON"], user_name = r["UserName"], hinhanh = r["AVATAR"], avatar = LiteController.genLinkAvatar(_config.LinkAPI, r["AVATAR"]), }; return(JsonResultCommon.ThanhCong(data)); //ID_khenthuong = r["ID_KHENTHUONG"], //tieude = r["TIEUDE"], //icon = r["LINK_ICON"], //Noidungkt = r["NOIDUNG_KHEN_THUONG"], //user_KT = r["USER_KT"], } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public object getDSThongDiepDetail(int id_td) { int status = 0; string Id = ""; string Token = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataTable dt_group = new DataTable(); DataTable dt_user = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = ""; DataTable dt_token = new DataTable(); try { using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { dt = cnn.CreateDataTable(@" select ID_THONGDIEP,TIEUDE,NOIDUNG,TYPEPOST,CreatedBy,CreatedDate,HOTEN,CHUCVU,AVATAR,COL_DISABLE from TBL_THONGDIEPCEO as td , TBL_USER as u,TBL_NHANVIEN as nv where u.ID_USER=td.CreatedBy and u.IDNV=nv.IDNV and ID_THONGDIEP=" + id_td, Conds); } var data = from g in dt.AsEnumerable() select new { id_thongdiep = g["ID_THONGDIEP"], title = g["TIEUDE"], noidung = g["NOIDUNG"], hoten = g["HOTEN"], chucvu = g["CHUCVU"], media = g["TYPEPOST"], ghim = g["COL_DISABLE"], imgmedia = LiteController.genLinkImage_Post(_config.LinkAPI, g["TYPEPOST"]), //user_name = r["UserName"], create_by = g["CreatedBy"], createdate = g["CreatedDate"], hinhanh = g["AVATAR"], AlowEdit = g["CreatedBy"], Avatar = LiteController.genLinkAvatar(_config.LinkAPI, g["AVATAR"]), }; return(JsonResultCommon.ThanhCong(data)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
public BaseModel <object> GetDSUser_profile_change() { { string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } int status = 0; string Id = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = ""; DataTable dt_token = new DataTable(); try { //Conds.Add("email", Email); //Conds.Add("password", Pass); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { dt = cnn.CreateDataTable(@"select ID_USER, u.IDNV,TINHTRANG, UserName, AVATAR, Pass, Email, nv.CHUCVU from TBL_Account as u, TBL_NHANVIEN as nv where u.IDNV = nv.IDNV and u.ID_USER="******"select * from LoginSection where Token = @token and Id = @Id_nv", Conds); } var data = from r in dt.AsEnumerable() select new { ID_user = r["ID_USER"], Username = r["UserName"], Password = r["Pass"], Email = r["Email"], chucvu = r["CHUCVU"], hinhanh = r["AVATAR"], Avatar = LiteController.genLinkAvatar(_config.LinkAPI, r["AVATAR"]), TinhTrang = r["TINHTRANG"], }; return(JsonResultCommon.ThanhCong(data)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public object getDSGhim(int id_user) { int status = 0; string Id = ""; string Token = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataTable dt_group = new DataTable(); DataTable dt_user = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = ""; DataTable dt_token = new DataTable(); try { using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { dt = cnn.CreateDataTable(@" SELECT * FROM TBL_GHIM as g,TBL_THONGDIEPCEO as td where g.ID_THONGDIEP=td.ID_THONGDIEP and ID_USER="******"ID_THONGDIEP"], title = g["TIEUDE"], noidung = g["NOIDUNG"], media = g["TYPEPOST"], imgmedia = LiteController.genLinkImage_Post(_config.LinkAPI, g["TYPEPOST"]), //id_user = r["ID_USER"], //user_name = r["UserName"], create_by = g["CreatedBy"], createdate = g["CreatedDate"], //hinhanh = g["AVATAR"], //AlowEdit = g["CreatedBy"], //Avatar = $"{link}/Avatar/{ g["AVATAR"]}", }; return(JsonResultCommon.ThanhCong(data)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
public object GetUserProfile() { { string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } int status = 0; string Id = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = ""; DataTable dt_token = new DataTable(); try { //Conds.Add("email", Email); //Conds.Add("password", Pass); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { dt = cnn.CreateDataTable(@" select ID_USER,nv.IDNV,UserName,AVATAR,DIACHI,NGAYSINH,SDT,GIOITINH from TBL_Account as u ,TBL_NHANVIEN as nv where u.IDNV=nv.IDNV and ID_USER="******"ID_USER"], ID_NV = r["IDNV"], Username = r["UserName"], hinhanh = r["AVATAR"], Avatar = LiteController.genLinkAvatar(_config.LinkAPI, r["AVATAR"]), diachi = r["DIACHI"], ngaysinh = r["NGAYSINH"], sdt = r["SDT"], gioitinh = r["GIOITINH"], }; return(JsonResultCommon.ThanhCong(data)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public object GetDS_MyMedia(int id_usser) { { int status = 0; string Id = ""; string Token = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = ""; DataTable dt_token = new DataTable(); try { //Conds.Add("email", Email); //Conds.Add("password", Pass); using (DpsConnection cnn = new DpsConnection("ConnectSQLMXH", true)) { dt = cnn.CreateDataTable(@" select ID_MEDIA,HINHANH,template,TIEUDE,CreatedBy,CreatedDate,UserName,AVATAR from TBL_MEDIA as me,TBL_Account as u where me.CreatedBy=u.ID_USER and me.CreatedBy=" + id_usser + "order by ID_MEDIA DESC" , Conds); //dt_token = cnn.CreateDataTable("select * from LoginSection where Token = @token and Id = @Id_nv", Conds); } var data = from r in dt.AsEnumerable() select new { id_media = r["ID_MEDIA"], img_media = r["HINHANH"], template = r["template"], hinhanh = LiteController.genLinkImage_Media(_config.LinkAPI, r["HINHANH"]), title = r["TIEUDE"], createdate = r["CreatedDate"], createby = r["CreatedBy"], username = r["UserName"], hinhanh_user = r["AVATAR"], Avatar = LiteController.genLinkAvatar(_config.LinkAPI, r["AVATAR"]), }; return(JsonResultCommon.ThanhCong(data)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public static ControllerContext GetControllerContext(this LiteController ctrl) { var ad = new ActionDiscoverer(new ParametersDiscoverer(Fakes.FakeServiceProvider.GetServiceProvider(), new Fakes.FakeDefaultLiteApiOptionsRetriever())); var controllerDiscoverer = new ControllerDiscoverer(ad, new LiteApiOptionsAccessor(LiteApiOptions.Default)); var type = ctrl.GetType(); var context = new ControllerContext { ControllerType = type, RouteAndName = GetControllerName(type, controllerDiscoverer) }; context.Actions = ad.GetActions(context); return(context); }
public static ControllerContext GetControllerContext(this LiteController ctrl) { var ad = new ActionDiscoverer(new ParametersDiscoverer(new Moq.Mock <IServiceProvider>().Object)); var controllerDiscoverer = new ControllerDiscoverer(ad); var type = ctrl.GetType(); var context = new ControllerContext { ControllerType = type, RouteAndName = GetControllerName(type, controllerDiscoverer) }; context.Actions = ad.GetActions(context); return(context); }
public object getRanDoomAnh() { int status = 0; string Id = ""; string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataTable dt_group = new DataTable(); DataTable dt_user = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = ""; DataTable dt_token = new DataTable(); try { using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { dt = cnn.CreateDataTable(@" select TOP 1 * from TBL_BAIDANG where CreatedBy=" + loginData.Id + " and TYPEPOST !=null or TYPEPOST!='' ORDER BY NEWID() ", Conds); } var data = from g in dt.AsEnumerable() select new { img = g["TYPEPOST"], hinhanh = LiteController.genLinkImage_Post(_config.LinkAPI, g["TYPEPOST"]), }; return(JsonResultCommon.ThanhCong(data)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
public object GetrandomDSUser() { { int status = 0; string Id = ""; string Token = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = ""; DataTable dt_token = new DataTable(); try { //Conds.Add("email", Email); //Conds.Add("password", Pass); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { dt = cnn.CreateDataTable(@"SELECT TOP 4 ID_USER,UserName,AVATAR FROM TBL_Account where TINHTRANG=1 ORDER BY NEWID()", Conds); //dt_token = cnn.CreateDataTable("select * from LoginSection where Token = @token and Id = @Id_nv", Conds); } var Data = from r in dt.AsEnumerable() select new { ID_user = r["ID_USER"], hinhanh = r["AVATAR"], Avatar = LiteController.genLinkAvatar(_config.LinkAPI, r["AVATAR"]), Username = r["UserName"], }; return(JsonResultCommon.ThanhCong(Data)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public object DataSource_Group(int id_group, [FromQuery] QueryParams query) { try { DataRow[] dr; PageModel pageModel = new PageModel(); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { string sqlq = @" select ID_GROUP, U.ID_USER, QUYEN_ADMIN , CREATE_DATE, IDNV, UserName, AVATAR from TBL_GROUPMEMBER AS G, TBL_Account AS U WHERE G.ID_USER = U.ID_USER and ID_GROUP=" + id_group; var dt = cnn.CreateDataTable(sqlq); if (cnn.LastError != null || dt == null) { return(JsonResultCommon.SQL(cnn.LastError.Message)); } var temp = dt.AsEnumerable(); #region Sort/filter Dictionary <string, string> sortableFields = new Dictionary <string, string> { { "UserName", "UserName" }, }; if (!string.IsNullOrEmpty(query.sortField) && sortableFields.ContainsKey(query.sortField)) { if ("asc".Equals(query.sortOrder)) { temp = temp.OrderBy(x => x[sortableFields[query.sortField]]); } else { temp = temp.OrderByDescending(x => x[sortableFields[query.sortField]]); } } var xaaaa = query.filter; if (!string.IsNullOrEmpty(query.filter["UserName"])) { string keyword = query.filter["UserName"].ToLower(); temp = temp.Where(x => x["UserName"].ToString().ToLower().Contains(keyword)); } #endregion int i = temp.Count(); if (i == 0) { return(JsonResultCommon.ThanhCong(new List <string>(), pageModel)); } dt = temp.CopyToDataTable(); int total = dt.Rows.Count; pageModel.TotalCount = total; pageModel.AllPage = (int)Math.Ceiling(total / (decimal)query.record); pageModel.Size = query.record; pageModel.Page = query.page; if (query.more) { query.page = 1; query.record = pageModel.TotalCount; } // Phân trang dt = dt.AsEnumerable().Skip((query.page - 1) * query.record).Take(query.record).CopyToDataTable(); var data = from r in dt.AsEnumerable() // where //r["ID_GROUP"].Equals(id_group) select new { Id_group = r["ID_GROUP"], id_user = r["ID_USER"], id_nv = r["IDNV"], Username = r["UserName"], quyen_group = r["QUYEN_ADMIN"], create_date = r["CREATE_DATE"], hinhanh = r["AVATAR"], Avatar = LiteController.genLinkAvatar(_config.LinkAPI, r["AVATAR"]), // Roles = r["roles"], }; return(JsonResultCommon.ThanhCong(data, pageModel)); } } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
public BaseModel <object> DS_ThanhVien_Group(int id_group, [FromBody] QueryRequestParams p) { string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } try { using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { Dictionary <string, string> _sortableFields = new Dictionary <string, string> { { "Username", "Username" }, //{ "DonViTinh", "DonViTinh" } }; Panigator v_panigator = null; IDictionary <string, string> v_dic_keyFilter = new Dictionary <string, string> { { "Username", "Username" }, //{ "DonViTinh", "DonViTinh"}, }; string _select = "", _sqlQuery = "", v_str_paginate = "", _orderBy = "", _whereCondition = ""; SqlConditions _cond = new SqlConditions(); #region Filter, sort, paganitor //filter request have to right and enough , same in code if (p.Filter != null) { if (p.Filter.Count > 0) { var listKeySearch = p.Filter.Where(x => !v_dic_keyFilter.ContainsKey(x.Key)).Select(q => q.Key).ToList(); if (listKeySearch != null && listKeySearch.Count > 0) { return(JsonResultCommon.NotData()); } foreach (string _filter in p.Filter.Keys) { if (!string.IsNullOrEmpty(p.Filter[_filter])) { foreach (string vl in p.Filter.Values) { //_whereCondition += " AND " + v_dic_keyFilter[_filter] + " = @" + _filter; _whereCondition += " AND " + v_dic_keyFilter[_filter] + " LIKE'%"; _whereCondition += vl; _whereCondition += "%'"; _cond.Add(_filter, p.Filter[_filter]); } } } } } //sort column in datatable if (p.Sort != null) { if (!string.IsNullOrEmpty(p.Sort.ColumnName) && v_dic_keyFilter.ContainsKey(p.Sort.ColumnName)) { _orderBy = v_dic_keyFilter[p.Sort.ColumnName] + " " + (p.Sort.Direction.ToLower().Equals("asc") ? "asc" : "desc"); } } int page_index = 0; //set up panigator for datatable if (p.Panigator != null) { //v_str_paginate = $@" OFFSET @PageSize * (@PageNumber - 1) ROWS FETCH NEXT @PageSize ROWS ONLY;"; //// offset fetch là các tùy chọn của mệnh đề order by //_cond.Add("PageSize", p.Panigator.PageSize); //_cond.Add("PageNumber", p.Panigator.PageIndex); page_index = p.Panigator.PageIndex; } #endregion _sqlQuery = $@" select ID_GROUP, U.ID_USER, QUYEN_ADMIN , CREATE_DATE, IDNV, UserName, AVATAR from TBL_GROUPMEMBER AS G, TBL_Account AS U WHERE G.ID_USER = U.ID_USER and ID_GROUP=" + id_group + "" + _whereCondition + ""; DataTable _datatable = cnn.CreateDataTable(_sqlQuery, _cond); int _countRows = _datatable.Rows.Count; if (cnn.LastError != null || _datatable == null) { return(JsonResultCommon.NotData()); } if (_datatable.Rows.Count == 0) { return(JsonResultCommon.NotData()); } else { if (page_index == 0) { p.Panigator.PageSize = _countRows; } v_panigator = new Panigator(p.Panigator.PageIndex, p.Panigator.PageSize, _datatable.Rows.Count); } var _data = from r in _datatable.AsEnumerable().Skip((p.Panigator.PageIndex - 1) * p.Panigator.PageSize).Take(p.Panigator.PageSize).ToList() select new { Id_group = r["ID_GROUP"], id_user = r["ID_USER"], id_nv = r["IDNV"], Username = r["UserName"], quyen_group = r["QUYEN_ADMIN"], create_date = r["CREATE_DATE"], hinhanh = r["AVATAR"], Avatar = LiteController.genLinkAvatar(_config.LinkAPI, r["AVATAR"]), }; return(JsonResultCommon.ThanhCong(_data, v_panigator)); } } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
public object getDSUser_Group(int id_group) { string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } int status = 0; string Id = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataTable dt_group = new DataTable(); DataTable dt_user = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = ""; DataTable dt_token = new DataTable(); try { //Conds.Add("email", Email); //Conds.Add("password", Pass); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { dt_group = cnn.CreateDataTable(@" select * from TBL_GROUP as g, TBL_GROUPMEMBER as u where g.ID_GROUP=u.ID_GROUP"); dt = cnn.CreateDataTable(@" select gu.ID_GROUP,g.TEN_GROUP,u.ID_USER,QUYEN_ADMIN,gu.CREATE_DATE as ngaythamgia,UserName,AVATAR,TINHTRANG from TBL_GROUPMEMBER as gu,TBL_Account as u , TBL_GROUP as g where gu.ID_USER=u.ID_USER and gu.ID_GROUP=g.ID_GROUP ", Conds); //dt_token = cnn.CreateDataTable("select * from LoginSection where Token = @token and Id = @Id_nv", Conds); } var data = from g in dt_group.AsEnumerable() where g["ID_GROUP"].Equals(id_group) && g["ID_USER"].ToString() == loginData.Id.ToString() select new { ID_group = g["ID_GROUP"], Ten_Group = g["TEN_GROUP"], id_user = g["ID_USER"], //id_user = r["ID_USER"], //user_name = r["UserName"], quyen_group = g["QUYEN_ADMIN"], //Create_date = r["ngaythamgia"], //tinhtrang = r["TINHTRANG"], //avatar_user = r["AVATAR"] //Icon_app = r["ICON_APP"], Group_member = from r in dt.AsEnumerable() where r["ID_GROUP"].Equals(g["ID_GROUP"]) select new { id_user = r["ID_USER"], user_name = r["UserName"], Create_date = r["ngaythamgia"], tinhtrang = r["TINHTRANG"], hinhanh = r["AVATAR"], avatar_user = LiteController.genLinkAvatar(_config.LinkAPI, r["AVATAR"]), //Icon_app = r["ICON_APP"], }, }; return(JsonResultCommon.ThanhCong(data)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
/// <summary> /// Invokes the specified <see cref="ActionContext"/>. /// </summary> /// <param name="httpCtx">The HTTP context, set by the middleware.</param> /// <param name="actionCtx">The action context.</param> /// <param name="logger">Logger to use, can be null</param> /// <returns></returns> public virtual async Task Invoke(HttpContext httpCtx, ActionContext actionCtx, ILogger logger = null) { logger?.LogInformation("Checking filters"); ApiFilterRunResult filterResult = await RunFiltersAndCheckIfShouldContinue(httpCtx, actionCtx); logger?.LogInformation($"Checking filters completed, can invoke: {filterResult.ShouldContinue}"); if (!filterResult.ShouldContinue) { int failedStatusCode = 0; if (filterResult.SetResponseCode.HasValue) { failedStatusCode = filterResult.SetResponseCode.Value; } else { bool isAuthenticated = httpCtx?.User?.Identity?.IsAuthenticated ?? false; if (isAuthenticated) { failedStatusCode = 403; } else { failedStatusCode = 401; } } httpCtx.Response.StatusCode = failedStatusCode; await httpCtx.Response.WriteAsync(filterResult.SetResponseMessage ?? "request rejected"); logger?.LogInformation($"returning response with status code: {failedStatusCode}"); return; } logger?.LogInformation($"Building controller: {actionCtx.ParentController}"); LiteController ctrl = _controllerBuilder.Build(actionCtx.ParentController, httpCtx); object[] paramValues = _modelBinder.GetParameterValues(httpCtx.Request, actionCtx); logger?.LogInformation($"Building controller succeeded: {actionCtx.ParentController}"); logger?.LogInformation($"Invoking action: {actionCtx}"); object result = null; bool isVoid = true; if (actionCtx.Method.ReturnType == typeof(void)) { actionCtx.Method.Invoke(ctrl, paramValues); } else if (actionCtx.Method.ReturnType == typeof(Task)) { var task = (actionCtx.Method.Invoke(ctrl, paramValues) as Task); await task; } else if (actionCtx.Method.ReturnType.IsConstructedGenericType && actionCtx.Method.ReturnType.GetGenericTypeDefinition() == typeof(Task <>)) { isVoid = false; var task = (dynamic)(actionCtx.Method.Invoke(ctrl, paramValues)); result = await task; } else { isVoid = false; result = actionCtx.Method.Invoke(ctrl, paramValues); } int?overridenResponseCode = httpCtx.GetResponseStatusCode(); if (overridenResponseCode.HasValue) { httpCtx.Response.StatusCode = overridenResponseCode.Value; } else { int statusCode = 405; // method not allowed switch (httpCtx.Request.Method.ToUpper()) { case "GET": statusCode = 200; break; case "POST": statusCode = 201; break; case "PUT": statusCode = 201; break; case "DELETE": statusCode = 204; break; } httpCtx.Response.StatusCode = statusCode; } httpCtx.Response.Headers.Add("X-Powered-By-Middleware", "LiteApi"); var additionalHeaders = httpCtx.GetResponseHeaders(true); if (additionalHeaders != null) { foreach (var header in additionalHeaders) { httpCtx.Response.Headers.Add(header.Key, header.Value); } } if (isVoid) { logger?.LogInformation("Not serializing result from invoked action, action is void or void task"); } else { logger?.LogInformation("Serializing result from invoked action"); if (actionCtx.IsReturningLiteActionResult) { await(result as ILiteActionResult).WriteResponse(httpCtx, actionCtx); } else { httpCtx.Response.ContentType = "application/json"; await httpCtx.Response.WriteAsync(_jsonSerializer.Serialize(result)); } } }
public static ControllerContext[] GetControllerContextAsArray(this LiteController ctrl) { return(new ControllerContext[] { ctrl.GetControllerContext() }); }
public object getDSBaiDangViewDetail(int id_baidang) { string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } PageModel pageModel = new PageModel(); string sql = ""; SqlConditions Conds = new SqlConditions(); DataTable dt_group = new DataTable(); DataTable dt_baidang = new DataTable(); DataTable dt_user = new DataTable(); DataTable dt_like_baidang = new DataTable(); DataTable dt_like_comment = new DataTable(); DataTable dt_comment = new DataTable(); DataTable dt_user_comment = new DataTable(); DataTable dt = new DataTable(); DataTable dt_like = new DataTable(); DataTable dt_comment_parent = new DataTable(); DataTable dt_icon = new DataTable(); DataTable dt_baidang_like_user = new DataTable(); DataTable dt_comment_like_user = new DataTable(); DataTable dt_kt = new DataTable(); DataRow[] dr; // DataRow[] dr; try { ////tesst tam //sql = @"select* from TBL_BAIDANG"; // code dung sql = @" select ID_BAIDANG,ID_LOAIBAIDANG,TIEUDE,NOIDUNG_BAIDANG,TYPEPOST,CreatedDate,CreatedBy,UpdateDate,UpdateBy,ID_KHENTHUONG,ID_GROUP from TBL_BAIDANG ORDER BY ID_BAIDANG DESC"; using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { dt = cnn.CreateDataTable(sql, Conds); dt_comment = cnn.CreateDataTable(@"select * from TBL_COMMENT"); dt_like = cnn.CreateDataTable(@"select * from TBL_COMMENT"); //dt_user_baidang = cnn.CreateDataTable(@"select * from TBL_USER"); dt_user = cnn.CreateDataTable(@"select * from TBL_Account"); dt_like_baidang = cnn.CreateDataTable(@" select l.ID_LIKE,likebd.ID_BAIDANG, l.title,count(likebd.ID_LIKE) as tong ,l.LINK_ICON from TBL_BAIDANG_LIKE as likebd ,TBL_LIKE as l where l.ID_LIKE=likebd.ID_LIKE and likebd.COL_DISABLED=0 group by l.title,likebd.ID_BAIDANG,l.ID_LIKE,l.LINK_ICON "); dt_user_comment = cnn.CreateDataTable(@"select * from TBL_Account"); dt_like_comment = cnn.CreateDataTable(@" select l.ID_LIKE,cmtlike.ID_COMMENT, l.title,count(cmtlike.ID_LIKE) as tong,l.LINK_ICON from TBL_COMMENT_LIKE as cmtlike ,TBL_LIKE as l where l.ID_LIKE=cmtlike.ID_LIKE and cmtlike.COL_DISABLED=0 group by l.title,cmtlike.ID_COMMENT,l.ID_LIKE,l.LINK_ICON "); dt_icon = cnn.CreateDataTable("select * from TBL_LIKE"); dt_baidang_like_user = cnn.CreateDataTable(@" select l.ID_LIKE,likebd.ID_BAIDANG, l.title,l.LINK_ICON,likebd.CREATE_BY,likebd.COL_DISABLED from TBL_BAIDANG_LIKE as likebd ,TBL_LIKE as l where l.ID_LIKE=likebd.ID_LIKE and likebd.COL_DISABLED=0 "); dt_comment_like_user = cnn.CreateDataTable(@" select l.ID_LIKE,like_cmt.ID_COMMENT, l.title,l.LINK_ICON,like_cmt.CREATE_BY from TBL_COMMENT_LIKE as like_cmt ,TBL_LIKE as l where l.ID_LIKE=like_cmt.ID_LIKE and like_cmt.COL_DISABLED=0 "); dt_comment_parent = cnn.CreateDataTable(@" SELECT * FROM TBL_COMMENT WHERE ID_COMMENT_PARENT !=0"); dt_kt = cnn.CreateDataTable(@" select * from TBL_KHENTHUONG "); dt_group = cnn.CreateDataTable(@" select ID_GROUP,TEN_GROUP from TBL_GROUP "); } var total = dt.Rows.Count; if (total == 0) { return(JsonResultCommon.ThanhCong(string.Empty, pageModel)); } // status = 1, var data = from r in dt.AsEnumerable() where r["ID_BAIDANG"].Equals(id_baidang) select new { Id_BaiDang = r["ID_BAIDANG"], Id_LoaiBaiDang = r["ID_LOAIBAIDANG"], title = r["TIEUDE"], NoiDung = r["NOIDUNG_BAIDANG"], CreatedDate = r["CreatedDate"], CreatedBy = r["CreatedBy"], hinhanh = r["TYPEPOST"], image = LiteController.genLinkImage_Post(_config.LinkAPI, r["TYPEPOST"]), //Id_Group = r["ID_GROUP"], UpdateDate = r["UpdateDate"], UpdateBy = r["UpdateBy"], id_khenthuong = r["ID_KHENTHUONG"], AllowEdit = r["CreatedBy"], Group = from g in dt_group.AsEnumerable() where r["ID_GROUP"].Equals(g["ID_GROUP"]) select new { id_group = g["ID_GROUP"], ten_group = g["TEN_GROUP"], //icon = g["LINK_ICON"], }, // bai dang duoc like KhenThuong = from kt in dt_kt.AsEnumerable() where r["ID_KHENTHUONG"].Equals(kt["ID_KHENTHUONG"]) select new { id_khenthuong = kt["ID_KHENTHUONG"], tieude_kt = kt["TIEUDE"], icon = kt["LINK_ICON"], }, Like = ( from lr in dt_baidang_like_user.AsEnumerable() where lr["ID_BAIDANG"].Equals(r["ID_BAIDANG"]) && lr["CREATE_BY"].Equals(loginData.Id) //&& lr["CreatedBy"].Equals(r["CreatedBy"])) select new { CreateBy = lr["CREATE_BY"], ID_like = lr["ID_LIKE"], title = lr["title"], icon = lr["LINK_ICON"], //icon_app = lr["ICON_APP"] }).FirstOrDefault(), //Like = ttt, Like_BaiDang = from like_bd in dt_like_baidang.AsEnumerable() where like_bd["ID_BAIDANG"].ToString().Equals(r["ID_BAIDANG"].ToString()) select new { ID_like = like_bd["ID_LIKE"], title = like_bd["title"], icon = like_bd["LINK_ICON"], //icon_app= like_bd["ICON_APP"], tong = like_bd["tong"], }, User_DangBai = from user in dt_user.AsEnumerable() where user["ID_USER"].ToString().Equals(r["CreatedBy"].ToString()) select new { ID_user = user["ID_USER"], Username = user["UserName"], ID_NV = user["IDNV"], hinhanh = user["AVATAR"], avatar = LiteController.genLinkAvatar(_config.LinkAPI, user["AVATAR"]), }, // Trong bai dang co nhung commet nao Coment = from h in dt_comment.AsEnumerable() where h["ID_BAIDANG"].ToString().Equals(r["ID_BAIDANG"].ToString()) select new { id_cmt = h["ID_COMMENT"], Id_BaiDang = h["ID_BAIDANG"], NoiDung_cmt = h["NOIDUNG_COMMENT"], typepost = h["TYPEPOST"], CreatedBy = h["CreatedBy_cmt"], CreatedDate = h["CreatedDate_cmt"], id_cmt_parent = h["ID_COMMENT_PARENT"], //Dan_Nhan = h["ID_DANNHAN"], UpdatedDate = h["UpdatedDate_cmt"], UpdatedBy = h["UpdatedBy_cmt"], AllowEdit = h["CreatedBy_cmt"], User_comment = from user in dt_user.AsEnumerable() where user["ID_USER"].ToString().Equals(h["CreatedBy_cmt"].ToString()) select new { ID_user = user["ID_USER"], Username = user["UserName"], ID_NV = user["IDNV"], hinhanh = user["AVATAR"], avatar = LiteController.genLinkAvatar(_config.LinkAPI, user["AVATAR"]), }, Like = ( from lr in dt_comment_like_user.AsEnumerable() where lr["ID_COMMENT"].Equals(h["ID_COMMENT"]) && lr["CREATE_BY"].Equals(loginData.Id) //&& lr["CreatedBy"].Equals(r["CreatedBy"])) select new { CreateBy = lr["CREATE_BY"], ID_like = lr["ID_LIKE"], title = lr["title"], icon = lr["LINK_ICON"], //icon_app = lr["ICON_APP"], }).FirstOrDefault(), Like_Comment = from like_cmt in dt_like_comment.AsEnumerable() where like_cmt["ID_COMMENT"].ToString().Equals(h["ID_COMMENT"].ToString()) select new { ID_like = like_cmt["ID_LIKE"], title = like_cmt["title"], icon = like_cmt["LINK_ICON"], //icon_app = like_cmt["ICON_APP"], tong = like_cmt["tong"], }, Comment_child = from like_cmt_chill in dt_comment_parent.AsEnumerable() where like_cmt_chill["ID_COMMENT_PARENT"].ToString().Equals(h["ID_COMMENT"].ToString()) select new { id_cmt = like_cmt_chill["ID_COMMENT"], Id_BaiDang = like_cmt_chill["ID_BAIDANG"], NoiDung_cmt = like_cmt_chill["NOIDUNG_COMMENT"], TypePost = like_cmt_chill["TYPEPOST"], CreatedBy_cmt = like_cmt_chill["CreatedBy_cmt"], CreatedDate_cmt = like_cmt_chill["CreatedDate_cmt"], id_cmt_parent = like_cmt_chill["ID_COMMENT_PARENT"], //Dan_Nhan = h["ID_DANNHAN"], UpdatedDate_cmt = like_cmt_chill["UpdatedDate_cmt"], UpdatedBy_cmt = like_cmt_chill["UpdatedBy_cmt"], AllowEdit = like_cmt_chill["CreatedBy_cmt"], User_comment_child = from user in dt_user.AsEnumerable() where user["ID_USER"].ToString().Equals(like_cmt_chill["CreatedBy_cmt"].ToString()) select new { ID_user = user["ID_USER"], Username = user["UserName"], ID_NV = user["IDNV"], hinhanh = user["AVATAR"], avatar = LiteController.genLinkAvatar(_config.LinkAPI, user["AVATAR"]), }, Like_child = ( from lr in dt_comment_like_user.AsEnumerable() where lr["ID_COMMENT"].Equals(like_cmt_chill["ID_COMMENT"]) && lr["CREATE_BY"].Equals(loginData.Id) //&& lr["CreatedBy"].Equals(r["CreatedBy"])) select new { CreateBy = lr["CREATE_BY"], ID_like = lr["ID_LIKE"], title = lr["title"], icon = lr["LINK_ICON"], //icon_app = lr["ICON_APP"], }).FirstOrDefault(), Like_Comment_child = from like_cmt in dt_like_comment.AsEnumerable() where like_cmt["ID_COMMENT"].ToString().Equals(like_cmt_chill["ID_COMMENT"].ToString()) select new { ID_like = like_cmt["ID_LIKE"], title = like_cmt["title"], icon = like_cmt["LINK_ICON"], //icon_app = like_cmt["ICON_APP"], tong = like_cmt["tong"], }, }, }, }; //CustemerID = loginData.IDKHDPS, return(JsonResultCommon.ThanhCong(data, pageModel)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
public object GetDataEDit(int id_baidang) { { int status = 0; string Id = ""; string Token = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = ""; DataTable dt_kt = new DataTable(); DataTable dt_token = new DataTable(); try { //Conds.Add("email", Email); //Conds.Add("password", Pass); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { dt_kt = cnn.CreateDataTable(@" select * from TBL_KHENTHUONG "); dt = cnn.CreateDataTable(@" select * from TBL_BAIDANG where ID_BAIDANG=" + id_baidang, Conds); //dt_token = cnn.CreateDataTable("select * from LoginSection where Token = @token and Id = @Id_nv", Conds); } var data = from r in dt.AsEnumerable() select new { Id_BaiDang = r["ID_BAIDANG"], Id_LoaiBaiDang = r["ID_LOAIBAIDANG"], title = r["TIEUDE"], NoiDung = r["NOIDUNG_BAIDANG"], CreatedDate = r["CreatedDate"], CreatedBy = r["CreatedBy"], Id_Group = r["ID_GROUP"], hinhanh = r["TYPEPOST"], image = LiteController.genLinkImage_Post(_config.LinkAPI, r["TYPEPOST"]), UpdateDate = r["UpdateDate"], UpdateBy = r["UpdateBy"], id_khenthuong = r["ID_KHENTHUONG"], AllowEdit = r["CreatedBy"], KhenThuong = from kt in dt_kt.AsEnumerable() where r["ID_KHENTHUONG"].Equals(kt["ID_KHENTHUONG"]) select new { id_khenthuong = kt["ID_KHENTHUONG"], tieude_kt = kt["TIEUDE"], icon = kt["LINK_ICON"], }, }; return(JsonResultCommon.ThanhCong(data)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }
public object getFlow(int id_canhan) { int status = 0; string Id = ""; string Token = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataTable dt_count = new DataTable(); DataTable dt_user = new DataTable(); DataTable checkflow = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = ""; DataTable dt_token = new DataTable(); try { using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { dt_user = cnn.CreateDataTable(@"select top 4 USER_Flow from TBL_Flow where ID_CANHAN=" + id_canhan + "ORDER by newid()", Conds); dt = cnn.CreateDataTable(@" select ID_USER,AVATAR,TINHTRANG from TBL_Account "); dt_count = cnn.CreateDataTable(@"select count(ID_CANHAN) as tong,ID_CANHAN from TBL_Flow where ID_CANHAN=" + id_canhan + "group by ID_CANHAN"); } var data = from g in dt_count.AsEnumerable() select new { tong = g["tong"], Flow = from cnt in dt_user.AsEnumerable() select new { user_flow = cnt["USER_Flow"], TT_User_Flow = from flow in dt.AsEnumerable() where flow["ID_USER"].Equals(cnt["USER_Flow"]) select new { TinhTrang = flow["TINHTRANG"], hinh = flow["AVATAR"], Avatar = LiteController.genLinkAvatar(_config.LinkAPI, flow["AVATAR"]), }, }, }; return(JsonResultCommon.ThanhCong(data)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
public object getDSBaiDangFlowTrangCaNhan(int id, [FromQuery] QueryParams_New query) { //string Token = lc.GetHeader(Request); //LoginData loginData = lc._GetInfoUser(Token); //if (loginData == null) // return JsonResultCommon.DangNhap(); PageModel pageModel = new PageModel(); string sql = ""; string sql_baidang = ""; SqlConditions Conds = new SqlConditions(); DataTable dt_baidang = new DataTable(); DataTable dt_user = new DataTable(); DataTable dt_like_baidang = new DataTable(); DataTable dt_like_comment = new DataTable(); DataTable dt_comment = new DataTable(); DataTable dt_user_comment = new DataTable(); DataTable dt = new DataTable(); DataTable dt_like = new DataTable(); DataTable dt_comment_parent = new DataTable(); DataTable dt_icon = new DataTable(); DataTable dt_baidang_like_user = new DataTable(); DataTable dt_comment_like_user = new DataTable(); DataTable dt_baidangcanhan = new DataTable(); DataTable dt_kt = new DataTable(); DataTable dt_group = new DataTable(); DataRow[] dr; // DataRow[] dr; try { sql_baidang = @" select ID_BAIDANG,CreatedDate from TBL_BAIDANG where CreatedBy=" + id + "UNION select ID_BAIDANG,CreatedDate from TBL_BaiDang_TRANGCANHAN where ID_USER="******" ORDER BY CreatedDate DESC"; sql = @" select ID_BAIDANG,ID_LOAIBAIDANG,TIEUDE,NOIDUNG_BAIDANG,TYPEPOST,CreatedDate,CreatedBy,UpdateDate,UpdateBy,ID_KHENTHUONG,ID_GROUP from TBL_BAIDANG ORDER BY ID_BAIDANG DESC"; using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { //dt = cnn.CreateDataTable(sql, Conds); dt_baidangcanhan = cnn.CreateDataTable(sql_baidang, Conds); Thread.Sleep(500); dt = cnn.CreateDataTable(sql); dt_comment = cnn.CreateDataTable(@"select * from TBL_COMMENT"); dt_like = cnn.CreateDataTable(@"select * from TBL_COMMENT"); //dt_user_baidang = cnn.CreateDataTable(@"select * from TBL_USER"); dt_user = cnn.CreateDataTable(@"select * from TBL_Account"); dt_like_baidang = cnn.CreateDataTable(@" select l.ID_LIKE,likebd.ID_BAIDANG, l.title,count(likebd.ID_LIKE) as tong ,l.LINK_ICON from TBL_BAIDANG_LIKE as likebd ,TBL_LIKE as l where l.ID_LIKE=likebd.ID_LIKE and likebd.COL_DISABLED=0 group by l.title,likebd.ID_BAIDANG,l.ID_LIKE,l.LINK_ICON "); dt_user_comment = cnn.CreateDataTable(@"select * from TBL_Account"); dt_like_comment = cnn.CreateDataTable(@" select top 3 l.ID_LIKE,cmtlike.ID_COMMENT, l.title,count(cmtlike.ID_LIKE) as tong,l.LINK_ICON from TBL_COMMENT_LIKE as cmtlike ,TBL_LIKE as l where l.ID_LIKE=cmtlike.ID_LIKE and cmtlike.COL_DISABLED=0 group by l.title,cmtlike.ID_COMMENT,l.ID_LIKE,l.LINK_ICON order by tong desc "); dt_icon = cnn.CreateDataTable("select * from TBL_LIKE"); dt_baidang_like_user = cnn.CreateDataTable(@" select l.ID_LIKE,likebd.ID_BAIDANG, l.title,l.LINK_ICON,likebd.CREATE_BY,likebd.COL_DISABLED from TBL_BAIDANG_LIKE as likebd ,TBL_LIKE as l where l.ID_LIKE=likebd.ID_LIKE and likebd.COL_DISABLED=0 "); dt_comment_like_user = cnn.CreateDataTable(@" select l.ID_LIKE,like_cmt.ID_COMMENT, l.title,l.LINK_ICON,like_cmt.CREATE_BY from TBL_COMMENT_LIKE as like_cmt ,TBL_LIKE as l where l.ID_LIKE=like_cmt.ID_LIKE and like_cmt.COL_DISABLED=0 "); dt_comment_parent = cnn.CreateDataTable(@" SELECT * FROM TBL_COMMENT WHERE ID_COMMENT_PARENT !=0"); dt_kt = cnn.CreateDataTable(@" select * from TBL_KHENTHUONG "); dt_group = cnn.CreateDataTable(@" select ID_GROUP,TEN_GROUP from TBL_GROUP "); } int total = dt_baidangcanhan.Rows.Count; pageModel.TotalCount = total; pageModel.AllPage = (int)Math.Ceiling(total / (decimal)query.record); pageModel.Size = query.record; pageModel.Page = query.page; if (query.more) { query.page = 1; query.record = pageModel.TotalCount; } if (query.page <= pageModel.AllPage) { dt_baidangcanhan = dt_baidangcanhan.AsEnumerable().Skip((query.page - 1) * query.record).Take(query.record).CopyToDataTable(); } else { return(JsonResultCommon.NotData()); } //lay anh usser //anh usser cmt var data = from p in dt_baidangcanhan.AsEnumerable() select new { Id_baidang_canhan = p["ID_BAIDANG"], DataBaiDang = from r in dt.AsEnumerable() where r["ID_BAIDANG"].ToString().Equals(p["ID_BAIDANG"].ToString()) select new { Id_BaiDang = r["ID_BAIDANG"], Id_LoaiBaiDang = r["ID_LOAIBAIDANG"], title = r["TIEUDE"], NoiDung = r["NOIDUNG_BAIDANG"], CreatedDate = r["CreatedDate"], CreatedBy = r["CreatedBy"], // Id_Group = r["ID_GROUP"], hinhanh = r["TYPEPOST"], image = LiteController.genLinkImage_Post(_config.LinkAPI, r["TYPEPOST"]), //UpdateDate = r["UpdateDate"], //UpdateBy = r["UpdateBy"], /// id_khenthuong = r["ID_KHENTHUONG"] AllowEdit = r["CreatedBy"], // bai dang duoc like Group = from g in dt_group.AsEnumerable() where r["ID_GROUP"].Equals(g["ID_GROUP"]) select new { id_group = g["ID_GROUP"], ten_group = g["TEN_GROUP"], //icon = g["LINK_ICON"], }, KhenThuong = from kt in dt_kt.AsEnumerable() where r["ID_KHENTHUONG"].Equals(kt["ID_KHENTHUONG"]) select new { id_khenthuong = kt["ID_KHENTHUONG"], tieude_kt = kt["TIEUDE"], icon = kt["LINK_ICON"], }, Like = dt_baidang_like_user == null ? null : ( from lr in dt_baidang_like_user.AsEnumerable() where lr["ID_BAIDANG"].Equals(r["ID_BAIDANG"]) && lr["CREATE_BY"].Equals(id) //&& lr["CreatedBy"].Equals(r["CreatedBy"])) select new { CreateBy = lr["CREATE_BY"], ID_like = lr["ID_LIKE"], title = lr["title"], icon = lr["LINK_ICON"], //icon_app = lr["ICON_APP"] }).FirstOrDefault(), //Like = ttt, Like_BaiDang = from like_bd in dt_like_baidang.AsEnumerable() where like_bd["ID_BAIDANG"].ToString().Equals(r["ID_BAIDANG"].ToString()) select new { ID_like = like_bd["ID_LIKE"], title = like_bd["title"], icon = like_bd["LINK_ICON"], //icon_app= like_bd["ICON_APP"], tong = like_bd["tong"], }, User_DangBai = from user in dt_user.AsEnumerable() where user["ID_USER"].ToString().Equals(r["CreatedBy"].ToString()) select new { ID_user = user["ID_USER"], Username = user["UserName"], ID_NV = user["IDNV"], hinhanh = user["AVATAR"], avatar = LiteController.genLinkAvatar(_config.LinkAPI, user["AVATAR"]), }, // Trong bai dang co nhung commet nao Coment = from h in dt_comment.AsEnumerable() where h["ID_BAIDANG"].ToString().Equals(r["ID_BAIDANG"].ToString()) select new { id_cmt = h["ID_COMMENT"], Id_BaiDang = h["ID_BAIDANG"], NoiDung_cmt = h["NOIDUNG_COMMENT"], typepost = h["TYPEPOST"], // hinh_cmt = $"{link}/UploadedFiles/{h["TYPEPOST"]}", CreatedBy = h["CreatedBy_cmt"], CreatedDate = h["CreatedDate_cmt"], id_cmt_parent = h["ID_COMMENT_PARENT"], //Dan_Nhan = h["ID_DANNHAN"], //UpdatedDate = h["UpdatedDate_cmt"], //UpdatedBy = h["UpdatedBy_cmt"], AllowEdit = h["CreatedBy_cmt"], User_comment = from user in dt_user.AsEnumerable() where user["ID_USER"].ToString().Equals(h["CreatedBy_cmt"].ToString()) select new { ID_user = user["ID_USER"], Username = user["UserName"], ID_NV = user["IDNV"], hinhanh = user["AVATAR"], avatar = LiteController.genLinkAvatar(_config.LinkAPI, user["AVATAR"]), }, Like = ( from lr in dt_comment_like_user.AsEnumerable() where lr["ID_COMMENT"].Equals(h["ID_COMMENT"]) && lr["CREATE_BY"].Equals(id ) //&& lr["CreatedBy"].Equals(r["CreatedBy"])) select new { CreateBy = lr["CREATE_BY"], ID_like = lr["ID_LIKE"], title = lr["title"], icon = lr["LINK_ICON"], //icon_app = lr["ICON_APP"], }).FirstOrDefault(), Like_Comment = from like_cmt in dt_like_comment.AsEnumerable() where like_cmt["ID_COMMENT"].ToString().Equals(h["ID_COMMENT"].ToString()) select new { ID_like = like_cmt["ID_LIKE"], title = like_cmt["title"], icon = like_cmt["LINK_ICON"], //icon_app = like_cmt["ICON_APP"], tong = like_cmt["tong"], }, Comment_child = from like_cmt_chill in dt_comment_parent.AsEnumerable() where like_cmt_chill["ID_COMMENT_PARENT"].ToString().Equals(h["ID_COMMENT"].ToString()) select new { id_cmt = like_cmt_chill["ID_COMMENT"], //Id_BaiDang = like_cmt_chill["ID_BAIDANG"], NoiDung_cmt = like_cmt_chill["NOIDUNG_COMMENT"], TypePost = like_cmt_chill["TYPEPOST"], // hinh_cmt = $"{link}/UploadedFiles/{like_cmt_chill["TYPEPOST"]}", CreatedBy = like_cmt_chill["CreatedBy_cmt"], CreatedDate = like_cmt_chill["CreatedDate_cmt"], id_cmt_parent = like_cmt_chill["ID_COMMENT_PARENT"], //Dan_Nhan = h["ID_DANNHAN"], //UpdatedDate_cmt = like_cmt_chill["UpdatedDate_cmt"], //UpdatedBy_cmt = like_cmt_chill["UpdatedBy_cmt"], AllowEdit = like_cmt_chill["CreatedBy_cmt"], User_comment_child = from user in dt_user.AsEnumerable() where user["ID_USER"].ToString().Equals(like_cmt_chill["CreatedBy_cmt"].ToString()) select new { ID_user = user["ID_USER"], Username = user["UserName"], ID_NV = user["IDNV"], hinhanh = user["AVATAR"], avatar = LiteController.genLinkAvatar(_config.LinkAPI, user["AVATAR"]), }, Like_child = ( from lr in dt_comment_like_user.AsEnumerable() where lr["ID_COMMENT"].Equals(like_cmt_chill["ID_COMMENT"]) && lr["CREATE_BY"].Equals(id ) //&& lr["CreatedBy"].Equals(r["CreatedBy"])) select new { CreateBy = lr["CREATE_BY"], ID_like = lr["ID_LIKE"], title = lr["title"], icon = lr["LINK_ICON"], //icon_app = lr["ICON_APP"], }).FirstOrDefault(), Like_Comment_child = from like_cmt in dt_like_comment.AsEnumerable() where like_cmt["ID_COMMENT"].ToString().Equals(like_cmt_chill["ID_COMMENT"].ToString()) select new { ID_like = like_cmt["ID_LIKE"], title = like_cmt["title"], icon = like_cmt["LINK_ICON"], }, }, }, }, }; //CustemerID = loginData.IDKHDPS, // page = pageModel; return(JsonResultCommon.ThanhCong(data, pageModel)); // ; ; ; } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } }
/// <summary> /// Tìm người dùng /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <returns></returns> public LoginData FindAsync(string userName, string password) { DataTable Tb = null; using (DpsConnection Conn = new DpsConnection(_config.ConnectionString)) { string sqlq = @"select ID_USER,nv.IDNV,UserName,AVATAR,TINHTRANG,nv.CHUCVU from TBL_Account as ac,TBL_NHANVIEN as nv where Email='" + userName + "' and Pass='******' and ac.IDNV=nv.IDNV"; Tb = Conn.CreateDataTable(sqlq); if (Tb == null || Tb.Rows.Count != 1) { return(null); } var rw = Tb.Rows[0]; //string hash = rw["Pass"].ToString(); //string pass = DpsLibs.Common.EncDec.Decrypt(hash, PASSWORD_ED); //if (password.Equals(pass)) { LoginData _Dpsuser = new LoginData(); _Dpsuser.ID_user = int.Parse(rw["ID_USER"].ToString()); _Dpsuser.Id = int.Parse(rw["ID_USER"].ToString()); _Dpsuser.Id_nv = int.Parse(rw["IDNV"].ToString()); _Dpsuser.UserName = rw["UserName"].ToString(); _Dpsuser.Avatar = LiteController.genLinkAvatar(_config.LinkAPI, rw["AVATAR"]); _Dpsuser.TinhTrang = bool.Parse(rw["TINHTRANG"].ToString()); _Dpsuser.chucvu = rw["CHUCVU"].ToString(); //_Dpsuser.FullName = rw["FullName"].ToString(); //_Dpsuser.ChucVu = rw["IdChucVu"] != DBNull.Value ? rw["IdChucVu"].ToString() : ""; //_Dpsuser.Email = rw["Email"] != DBNull.Value ? rw["Email"].ToString() : ""; //_Dpsuser.SDT = rw["PhoneNumber"] != DBNull.Value ? rw["PhoneNumber"].ToString() : ""; //_Dpsuser.IdDonVi = rw["IdDonVi"] != DBNull.Value ? int.Parse(rw["IdDonVi"].ToString()) : 0; //_Dpsuser.Capcocau = rw["Capcocau"] != DBNull.Value ? int.Parse(rw["Capcocau"].ToString()) : 0; //_Dpsuser.ID_Goc = rw["ID_Goc"] != DBNull.Value ? int.Parse(rw["ID_Goc"].ToString()) : 0; //_Dpsuser.ID_Goc_Cha = rw["ID_Goc_Cha"] != DBNull.Value ? int.Parse(rw["ID_Goc_Cha"].ToString()) : 0; //_Dpsuser.DonVi = rw["DonVi"] != DBNull.Value ? rw["DonVi"].ToString() : ""; //_Dpsuser.MaDinhDanh = rw["MaDinhDanh"] != DBNull.Value ? rw["MaDinhDanh"].ToString() : ""; //_Dpsuser.Active = rw["Active"] != DBNull.Value ? int.Parse(rw["Active"].ToString()) : 0; //_Dpsuser.Avata = LiteController.genLinkAvatar(_config.LinkAPI, rw["Avata"]); //_Dpsuser.LastUpdatePass = (DateTime)rw["LastUpdatePass"]; //_Dpsuser.IdTinh = long.Parse(_config.IdTinh); //string str = "select * from Sys_Config where Code='EXP_PASS'"; //DataTable conf = Conn.CreateDataTable(str); //if (conf != null && conf.Rows.Count > 0) //{ // int num = int.Parse(conf.Rows[0]["Value"].ToString()); // if (num == 0)//k xét thời hạn // _Dpsuser.ExpDate = null; // else // { // DateTime exp = _Dpsuser.LastUpdatePass.AddDays(num + (int)rw["GiaHan"]); // _Dpsuser.ExpDate = exp; // } //} return(_Dpsuser); } } return(null); }
public BaseModel <object> GetDSUser() { { string Token = lc.GetHeader(Request); LoginData loginData = lc._GetInfoUser(Token); if (loginData == null) { return(JsonResultCommon.DangNhap()); } int status = 0; string Id = ""; SqlConditions Conds = new SqlConditions(); DataTable dt = new DataTable(); DataRow[] dr; bool Visible = true; List <object> rs = new List <object>(); string title = ""; // string link = Data_API_MXH.Assets.Common.getDomain(); DataTable dt_token = new DataTable(); try { //Conds.Add("email", Email); //Conds.Add("password", Pass); using (DpsConnection cnn = new DpsConnection(_config.ConnectionString)) { dt = cnn.CreateDataTable("select * from TBL_Account", Conds); //dt_token = cnn.CreateDataTable("select * from LoginSection where Token = @token and Id = @Id_nv", Conds); } // status = 1; var Data = from r in dt.AsEnumerable() select new { ID_user = r["ID_USER"], ID_NV = r["IDNV"], Username = r["UserName"], Password = r["Pass"], Email = r["Email"], // Token = r["Token"], TinhTrang = r["TINHTRANG"], // Roles = r["roles"], hinhanh = r["AVATAR"], Avatar = LiteController.genLinkAvatar(_config.LinkAPI, r["AVATAR"]), //Occupation = r["occupation"], //Phoned = r["Phone"], //Address = r["Address"], }; return(JsonResultCommon.ThanhCong(Data)); } catch (Exception ex) { return(JsonResultCommon.Exception(ex)); } } }