public HttpResponseMessage MarkMessageAsRead(ListOfIntsRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <bool> response; switch (model == null) { case true: response = new ItemResponse <bool> { Item = false }; break; default: bool isSuccess = MessageService.MarkMessagesAsReadById(model); response = new ItemResponse <bool> { Item = isSuccess }; break; } return(Request.CreateResponse(HttpStatusCode.OK, response)); }
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public static bool MarkMessagesAsReadById(ListOfIntsRequest model) { bool isSuccess = false; try { foreach (int messageId in model.Items) { UpdateMessageAsRead(messageId); } isSuccess = true; } catch (Exception ex) { throw ex; } return(isSuccess); }