Example #1
0
        public HttpResponseMessage GetListDepartment(DepartmentSearchCondition model)
        {
            try
            {
                var listResult = departmentBusiness.GetListDepartment(model);

                return(Request.CreateResponse(HttpStatusCode.OK, listResult));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Example #2
0
        public List <DepartmentSearchResult> GetListDepartment(DepartmentSearchCondition model)
        {
            try
            {
                var listDepartment = (from d in db.Department.AsNoTracking()
                                      where d.Name.Contains(model.Name)
                                      orderby d.Name
                                      select new DepartmentSearchResult()
                {
                    DepartmentId = d.DepartmentId,
                    Name = d.Name,
                    Description = d.Description
                }).ToList();

                return(listDepartment);
            }
            catch (Exception ex)
            {
                throw new ErrorException(ErrorMessage.ERR001, ex.InnerException);
            }
        }