TaskResult<bool> IGroupDataService.CreateGroup(GroupDetail group)
        {
            TaskResult<bool> result = null;
            HttpClient client = GetHTTPClient();
            var content = new ObjectContent(typeof(GroupDetail), group, new JsonMediaTypeFormatter());
            HttpResponseMessage response = client.PostAsync("api/Group/CreateGroup", content).Result;

            if (response.IsSuccessStatusCode)
            {
                result = response.Content.ReadAsAsync<TaskResult<bool>>().Result;

            }
            else
            {
                result = new TaskResult<bool> { state = StatusState.CancelState, Data = false };
            }
            return result;
        }
Пример #2
0
 public TaskResult<bool> SaveGroup(GroupDetail group)
 {
     TaskResult<bool> result= null;
     try
     {
         if(group.Id==null)//insert
         {
             _groupRepository.Insert(new Group { DateCreated = DateTime.Now, Description = group.Description, Name = group.Name });
             _groupRepository.SaveChanges();
             result= new TaskResult<bool>{Data=true,state=StatusState.DoneState};
         }
     }
     catch(Exception e)
     {
         Logger.Instance.LogException(e);
         result= new TaskResult<bool>{Data=false,state=StatusState.CancelState};
     }
     return result;
 }