示例#1
0
        public ModelResponse ListByOrgContact(UserInfo user, long?id = null, int langId = 1, bool brief = false)
        {
            List <JobVm> ds;
            long         contactId = -1;

            try
            {
                //Authorization
                if (user == null)
                {
                    return(new ModelResponse(101));
                }
                if (brief || !DalFactory.Singleton.DataService.IsAdmin(user.UserId))
                {
                    if (!IsAuthorized(user))
                    {
                        return(new ModelResponse(101));
                    }
                    contactId = (long)user.OrgContactId.GetValueOrDefault();
                }

                if (brief)
                {
                    ds = Repo.BriefByOrgContact(contactId, id, langId);
                }
                else
                {
                    ds = Repo.ListByOrgContact(contactId, id, langId);
                }

                if (id > 0 && ds.Count != 1)
                {
                    return(new ModelResponse(101));
                }
            }
            catch (Exception ex)
            {
                return(new ModelResponse(ex));
            }

            return(id > 0 ? new ModelResponse(0, ds[0]) : new ModelResponse(0, ds));
        }