public HttpResponseMessage RemoveGroup(PhoneBookModel phonebookInfo) { var principal = Thread.CurrentPrincipal; if (!principal.Identity.IsAuthenticated) { throw new BusinessException(HttpStatusCode.Accepted, ErrorCode.AccountIsInvalid, Language.GetString("AccountIsInvalid")); } Common.User userInfo = ((MyPrincipal)principal).UserDetails; Facade.PhoneBook.DeleteItemFromPhoneBook(phonebookInfo.PhoneBookGuid); PhoneBookResponse response = new PhoneBookResponse(); response.IsSuccessful = true; return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public HttpResponseMessage AddGroup(PhoneBookModel phonebookInfo) { Common.PhoneBook phoneBook = new Common.PhoneBook(); PhoneBookResponseModel phonebookResponse = new PhoneBookResponseModel(); List <PhoneBookResponseModel> lstGroups = new List <PhoneBookResponseModel>(); var principal = Thread.CurrentPrincipal; if (!principal.Identity.IsAuthenticated) { throw new BusinessException(HttpStatusCode.Accepted, ErrorCode.AccountIsInvalid, Language.GetString("AccountIsInvalid")); } if (string.IsNullOrEmpty(phonebookInfo.Name)) { throw new BusinessException(HttpStatusCode.Accepted, ErrorCode.BadRequest, Language.GetString("BadRequest")); } Common.User userInfo = ((MyPrincipal)principal).UserDetails; phoneBook.Name = phonebookInfo.Name; phoneBook.ParentGuid = Guid.Empty; phoneBook.IsPrivate = false; phoneBook.UserGuid = userInfo.UserGuid; phoneBook.CreateDate = DateTime.Now; phoneBook.Type = (int)PhoneBookGroupType.Normal; Guid guid = Facade.PhoneBook.InsertItemInPhoneBook(phoneBook); phonebookResponse.Name = phoneBook.Name; phonebookResponse.PhoneBookGuid = guid; lstGroups.Add(phonebookResponse); PhoneBookResponse response = new PhoneBookResponse(); response.IsSuccessful = true; response.PhoneBooks = lstGroups; return(Request.CreateResponse(HttpStatusCode.OK, response)); }