public IHttpActionResult Get(int id) { DTO_SYS_Form tbl_SYS_Form = BS_SYS_Form.get_SYS_Form(db, id); if (tbl_SYS_Form == null) { return(NotFound()); } return(Ok(tbl_SYS_Form)); }
public List <DTO_APP_FormGroup> Get() { return(BS_SYS_Form.get_SYS_Form(db, PartnerID, AppRole)); }
public DTO_APP_UserInfo GetUserInfo() { DTO_APP_UserInfo result = new DTO_APP_UserInfo(); result.Id = ""; result.Roles = new DTO_AppRole(); result.Roles.CUSRoles = new List <int>(); result.Roles.SYSRoles = new List <string>(); result.Partners = new List <DTO_Partner>(); result.MenuItems = new List <DTO_APP_FormGroup>(); if (User.Identity.IsAuthenticated) { ApplicationUser user = UserManager.FindById(User.Identity.GetUserId()); if (user != null) { result.Id = user.Id; result.UserName = user.UserName; result.Email = user.Email; result.PartnerID = user.PartnerID; result.StaffID = user.StaffID; result.FullName = user.FullName; result.PhoneNumber = user.PhoneNumber; result.Avatar = user.Avatar; var CUSRoles = db.tbl_CUS_SYS_Role.Where(d => d.tbl_CUS_HRM_STAFF_NhanSu.Any(s => s.ID == user.StaffID)); foreach (var ro in CUSRoles) { result.Roles.CUSRoles.Add(ro.ID); } foreach (var ro in user.Roles) { result.Roles.SYSRoles.Add(ro.RoleId); } } } //if (result.Roles.SYSRoles.Count == 0 && result.Roles.CUSRoles.Count == 0) //{ // result.Roles.SYSRoles.Add("GUEST"); //} if (QueryStrings.Any(d => d.Key == "GetMenu")) { var qValue = QueryStrings.FirstOrDefault(d => d.Key == "GetMenu").Value; if (bool.TryParse(qValue, out bool qBoolValue)) { result.MenuItems = BS_SYS_Form.get_SYS_Form(db, PartnerID, result.Roles); if (result.Roles.SYSRoles.Contains("HOST")) { var partners = BS_PAR_Partner.get_PAR_Partner(db, QueryStrings).Select(partner => new DTO_Partner() { ID = partner.ID, Code = partner.Code, Name = partner.Name, LogoURL = partner.LogoURL, Remark = partner.Remark, BannerURL = partner.BannerURL, TemplateHeader = partner.TemplateHeader, TemplateFooter = partner.TemplateFooter }); result.Partners = partners.ToList(); } else { var partner = BS_PAR_Partner.get_PAR_Partner(db, result.PartnerID); if (partner != null) { result.Partners.Add(new DTO_Partner() { ID = partner.ID, Code = partner.Code, Name = partner.Name, LogoURL = partner.LogoURL, Remark = partner.Remark, BannerURL = partner.BannerURL, TemplateHeader = partner.TemplateHeader, TemplateFooter = partner.TemplateFooter }); } } } } //if (result.MenuItems == null) // result.MenuItems = new List<DTO_APP_FormGroup>(); if (User.Identity.IsAuthenticated) { if (result.MenuItems != null && result.MenuItems.Count > 0) { result.MenuItems.Insert(0, new DTO_APP_FormGroup { ID = 0, AppID = 0, Code = "Home", AppName = "Home", FormMenu = new List <DTO_APP_Form> { new DTO_APP_Form { ID = 0, Code = "page-default", Name = "Home", IsHiddenMenu = true } }, Forms = new List <DTO_APP_Form> { new DTO_APP_Form { ID = 0, Code = "page-default", Name = "Home", IsHiddenMenu = true } } }); } } return(result); }