示例#1
0
        public IActionResult Get(string projectNumber, string wbsNumber, string searchValue, int skip, int take, string sortField, string dir)
        {
            try
            {
                if (string.IsNullOrEmpty(sortField))
                {
                    sortField = "CreatedOn";
                }
                var result = _wbsDictionaryService.GetWbsDictionary(projectNumber, wbsNumber, searchValue, skip, take, sortField, dir);
                var count  = _wbsDictionaryService.GetWbsDictionaryCount(projectNumber, wbsNumber, searchValue);
                var list   = new List <WbsDictionaryViewModel>();
                foreach (var dict in result)
                {
                    var user    = _userService.GetUserByUserGuid(dict.CreatedBy);
                    var whoUser = user == null ? "" : FormatHelper.FormatFullName(user.Firstname, string.Empty, user.Lastname);

                    list.Add(new WbsDictionaryViewModel
                    {
                        ProjectNumber      = dict.ProjectNumber,
                        CreatedBy          = dict.CreatedBy,
                        CreatedOn          = dict.CreatedOn,
                        WbsDictionaryGuid  = dict.WbsDictionaryGuid,
                        WbsDictionaryTitle = dict.WbsDictionaryTitle,
                        WbsNumber          = dict.WbsDictionaryTitle,
                        CreatedByName      = whoUser
                    });
                }

                if (!string.IsNullOrEmpty(sortField))
                {
                    if (sortField.ToLower().Equals("createdon"))
                    {
                        if (dir.ToLower().Equals("asc"))
                        {
                            list = list.OrderBy(x => x.CreatedByName).ToList();
                        }
                        else
                        {
                            list = list.OrderByDescending(x => x.CreatedByName).ToList();
                        }
                    }
                }

                return(Json(new { result = list, count }));
            }
            catch (Exception ex)
            {
                ModelState.Clear();
                ModelState.AddModelError("", ex.Message);
                return(BadRequestFormatter.BadRequest(this, ex));
            }
        }
示例#2
0
 public IActionResult Get(string projectNumber, bool excludeIWOs, string searchValue, int skip, int take, string orderBy, string dir)
 {
     try
     {
         if (string.IsNullOrEmpty(orderBy))
         {
             orderBy = "wbs";
         }
         var result = _wbsService.GetWbs(projectNumber, searchValue, skip, take, orderBy, dir, new List <AdvancedSearchRequest>());
         var count  = _wbsService.GetCount(projectNumber, searchValue, new List <AdvancedSearchRequest>());
         var list   = new List <WbsViewModel>();
         foreach (var wbs in result)
         {
             var dictionaries = _wbsDictionaryService.GetWbsDictionary(wbs.ProjectNumber, wbs.Wbs, "", 0, 4, "CreatedOn", "ASC");
             var item         = new WbsViewModel {
                 WbsGuid            = wbs.WbsGuid,
                 Description        = wbs.Description,
                 Wbs                = wbs.Wbs,
                 AllowCharging      = wbs.AllowCharging,
                 ProjectNumber      = wbs.ProjectNumber,
                 WbsDictionaryTitle = new List <string>()
             };
             foreach (var d in dictionaries)
             {
                 item.WbsDictionaryTitle.Add(d.WbsDictionaryTitle);
             }
             list.Add(item);
         }
         return(Json(new { result = list, count }));
     }
     catch (Exception ex)
     {
         ModelState.Clear();
         ModelState.AddModelError("", ex.Message);
         return(BadRequestFormatter.BadRequest(this, ex));
     }
 }