Example #1
0
        public ActionResult GetAllAccountGroup()
        {
            List <AccountGroup> category = service.GetAll();

            if (category == null)
            {
                return(HttpNotFound());
            }
            var result = AutoMapper.Mapper.Map <List <AccountGroup>, List <AccountGroupResponse> >(category);

            foreach (var item in result)
            {
                if (item.GroupUnder == 0 || item.GroupUnder == -1)
                {
                    item.Under = "Primary";
                }
                else
                {
                    item.Under = result.Where(a => a.Id == item.GroupUnder).FirstOrDefault().AccountGroupName;
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }