//Constructor for Adding a URole public URole AddURole(URole urole) { urole.ValidFrom = DateTime.Now; _uroleContext.uRoles.Add(urole); _uroleContext.SaveChanges(); //saving added URole to table return(urole); }
public async Task <IActionResult> AddRole([FromRoute] Guid userId, [FromBody] URole role) { var user = await _userService.AddRole(userId, role.RoleId); if (user.IsSucceed) { return(Ok(user)); } return(BadRequest(user.FailureResult)); }
public IActionResult EditURole(int Id, URole uRole) { var existingURole = _uRoleData.GetURole(Id); if (existingURole != null) { uRole.Id = existingURole.Id; _uRoleData.EditURole(uRole); return(Ok(uRole)); } return(NotFound($"URole with Id : {Id} was not found")); }
//Constructor for Deleting a URole public void DeleteURole(URole urole) { var delURole = GetURole(urole.Id); if (delURole == null) { throw new InvalidOperationException("Invalid Role Id"); } else { _uroleContext.Remove(delURole); _uroleContext.SaveChanges(); //deletion of URole and saving changes to table } }
public void addRole(RoleAuthModel ram, string[] auth) { var r = new URole { Name = ram.Name, Description = ram.Description, }; this.Roles.Insert(r); foreach (var item in auth) { this.RoleAuthorises.Insert(new URoleAuthorise { RoleID = r.RoleID, AuthoriseID = int.Parse(item) }); } }
//Constructor for Updating an existing URole public URole EditURole(URole urole) { var existingURole = GetURole(urole.Id); if (existingURole == null) { throw new InvalidOperationException("Invalid input"); } else { existingURole.ValidFrom = urole.ValidFrom; existingURole.ValidTo = urole.ValidTo; _uroleContext.uRoles.Update(existingURole); _uroleContext.SaveChanges(); ///Saving changes to table after Update return(urole); } }
/// <summary> /// 商铺信息下拉刷新 /// </summary> /// <param name="model"></param> /// <returns></returns> public Dictionary <string, object> GetMerchantList(wy_houseinfo model, string userID, URole role) { Dictionary <string, object> dic = new Dictionary <string, object>(); try { var list = _Db.Db().Queryable <wy_houseinfo>().Where(a => a.IS_DELETE == 0); if (role == URole.Admin) { list = _Db.Db().Queryable <wy_houseinfo, ts_uidp_org, ts_uidp_org_user>((a, b, c) => new object[] { JoinType.Inner, a.ORG_CODE.StartsWith(b.ORG_CODE), JoinType.Inner, b.ORG_ID == c.ORG_ID && c.USER_ID == userID }).Where((a, b, c) => a.IS_DELETE == 0); } else if (role == URole.Inspector) { list = _Db.Db().Queryable <wy_houseinfo, wy_region_director>((a, b) => new object[] { JoinType.Inner, a.SSQY == b.SSQY && b.RD_ID == userID, }).Where((a, b) => a.IS_DELETE == 0); } if (!string.IsNullOrWhiteSpace(model.FWBH)) { list = list.Where(a => a.FWBH.Contains(model.FWBH)); } if (model.FWSX != null && model.FWSX != -1) { list = list.Where(a => a.FWSX == model.FWSX); } if (!string.IsNullOrWhiteSpace(model.SSQY)) { list = list.Where(a => a.SSQY == model.SSQY); } if (!string.IsNullOrWhiteSpace(model.LSFGS)) { list = list.Where(a => a.LSFGS == model.LSFGS); } var _list = list.ToList(); var count = from p in _list where p.FWSX == 2 select p; var greenCount = (from p in _list where p.FWSX == 2 select p).Count(); var grayCount = (from p in _list where p.FWSX == 0 select p).Count(); var yellowCount = (from p in _list where p.FWSX == 1 select p).Count(); var listNnew = list.Select(a => new { a.FWBH, a.FWMC, a.FWID, a.FWSX }).OrderBy(a => a.FWBH).Take(20).ToList(); dic.Add("list", listNnew); dic.Add("greenCount", greenCount); dic.Add("grayCount", grayCount); dic.Add("yellowCount", yellowCount); } catch (Exception ex) { dic.Add("list", null); dic.Add("greenCount", 0); dic.Add("grayCount", 0); dic.Add("yellowCount", 0); } return(dic); }
public Dictionary <string, object> GetShopInfoList(string ShopName, int FWSX, string SSQY, string LSFGS, string userID, URole role) { Dictionary <string, object> dic = new Dictionary <string, object>(); try { var obj = _Db.Db().Queryable <wy_houseinfo, wy_shopinfo, wy_leasinginfo>((a, b, c) => new object[] { JoinType.Inner, a.CZ_SHID == b.CZ_SHID, JoinType.Left, b.LEASE_ID == c.LEASE_ID }).Where((a, b, c) => a.IS_DELETE == 0 && b.IS_DELETE == 0).WhereIF(!string.IsNullOrWhiteSpace(ShopName), (a, b) => b.ZHXM.Contains(ShopName)) .WhereIF(FWSX > 0, (a, b) => a.FWSX == FWSX) .WhereIF(!string.IsNullOrWhiteSpace(SSQY), (a, b) => a.SSQY == SSQY) .WhereIF(!string.IsNullOrWhiteSpace(LSFGS), (a, b) => a.LSFGS == LSFGS) .Select((a, b, c) => new { a.FWMC, a.ZLWZ, b.CZ_SHID, b.ZHXM, a.FWID, FWSX = a.FWSX == 1 ? "出租" : "出售", c.ZLKSSJ, c.ZLZZSJ }).OrderBy(a => a.FWMC).ToList(); if (role == URole.Admin) { obj = _Db.Db().Queryable <wy_houseinfo, wy_shopinfo, wy_leasinginfo, ts_uidp_org, ts_uidp_org_user>((a, b, c, d, e) => new object[] { JoinType.Inner, a.CZ_SHID == b.CZ_SHID, JoinType.Left, b.LEASE_ID == c.LEASE_ID, JoinType.Inner, a.ORG_CODE.StartsWith(d.ORG_CODE), JoinType.Inner, d.ORG_ID == e.ORG_ID && e.USER_ID == userID }).Where((a, b, c) => a.IS_DELETE == 0 && b.IS_DELETE == 0).WhereIF(!string.IsNullOrWhiteSpace(ShopName), (a, b) => b.ZHXM.Contains(ShopName)) .WhereIF(FWSX > 0, (a, b) => a.FWSX == FWSX) .WhereIF(!string.IsNullOrWhiteSpace(SSQY), (a, b) => a.SSQY == SSQY) .WhereIF(!string.IsNullOrWhiteSpace(LSFGS), (a, b) => a.LSFGS == LSFGS) .Select((a, b, c) => new { a.FWMC, a.ZLWZ, b.CZ_SHID, b.ZHXM, a.FWID, FWSX = a.FWSX == 1 ? "出租" : "出售", ZLKSSJ = c.ZLKSSJ, ZLZZSJ = c.ZLZZSJ }).OrderBy(a => a.FWMC).Take(20).ToList(); } else if (role == URole.Inspector) { obj = _Db.Db().Queryable <wy_houseinfo, wy_shopinfo, wy_leasinginfo, wy_region_director>((a, b, c, d) => new object[] { JoinType.Inner, a.CZ_SHID == b.CZ_SHID, JoinType.Left, b.LEASE_ID == c.LEASE_ID, JoinType.Inner, a.SSQY == d.SSQY && d.RD_ID == userID, }).Where((a, b, c) => a.IS_DELETE == 0 && b.IS_DELETE == 0).WhereIF(!string.IsNullOrWhiteSpace(ShopName), (a, b) => b.ZHXM.Contains(ShopName)) .WhereIF(FWSX > 0, (a, b) => a.FWSX == FWSX) .WhereIF(!string.IsNullOrWhiteSpace(SSQY), (a, b) => a.SSQY == SSQY) .WhereIF(!string.IsNullOrWhiteSpace(LSFGS), (a, b) => a.LSFGS == LSFGS) .Select((a, b, c) => new { a.FWMC, a.ZLWZ, b.CZ_SHID, b.ZHXM, a.FWID, FWSX = a.FWSX == 1 ? "出租" : "出售", ZLKSSJ = c.ZLKSSJ, ZLZZSJ = c.ZLZZSJ }).OrderBy(a => a.FWMC).Take(20).ToList(); } dic.Add("list", obj); } catch (Exception ex) { dic.Add("list", null); } return(dic); }
public IActionResult AddURole(URole uRole) { _uRoleData.AddURole(uRole); return(Created(HttpContext.Request.Scheme + "://" + HttpContext.Request.Host + HttpContext.Request.Path + uRole.Id, uRole)); }