//Create public TriggerResponse Post(TriggerRequest request) { TriggerResponse response = new TriggerResponse (); response.dateFrom = request.dateFrom; response.dateTo = request.dateTo; response.delay = request.delay; response.extra = request.extra; response.perUserRunCount = request.perUserRunCount; response.placeID = request.placeId; response.text = request.text; response.timeFrom = request.timeFrom; response.timeTo = request.timeTo; response.type = request.type; WriteConcernResult result = triggerscollection.Insert (response); response.responseStatus = new ResponseStatus (); if (result.Ok) { response.responseStatus.ErrorCode = "200"; response.responseStatus.Message = "SUCCESS"; } else { response.responseStatus.ErrorCode = "500"; response.responseStatus.Message = "FAILURE"; } return response; }
//Update public TriggerResponse Put(TriggerRequest request) { TriggerResponse response = new TriggerResponse (); var query = Query.EQ ("_id", request.Id); //var trigger = triggerscollection.FindOneAs<TriggerResponse> (query); response.Id = request.Id; response.placeID = request.placeId; response.dateFrom = request.dateFrom; response.dateTo = request.dateTo; response.delay = request.delay; response.extra = request.extra; response.perUserRunCount = request.perUserRunCount; response.text = request.text; response.timeFrom = request.timeFrom; response.timeTo = request.timeTo; response.type = request.type; var update = Update.Replace (response); FindAndModifyResult result = triggerscollection.FindAndModify (query, SortBy.Null, update); response.responseStatus = new ResponseStatus (); if (result.Ok) { response.responseStatus.ErrorCode = "200"; response.responseStatus.Message = "SUCCESS"; } else { response.responseStatus.ErrorCode = "500"; response.responseStatus.Message = "FAILURE"; } return response; }
//Info public TriggerResponse Get(TriggerRequest request) { TriggerResponse response = new TriggerResponse (); var query = Query.EQ ("_id", request.Id); var trigger = triggerscollection.FindOneAs<TriggerResponse> (query); response.dateFrom = trigger.dateFrom; response.dateTo = trigger.dateTo; response.delay = trigger.delay; response.extra = trigger.extra; response.Id = trigger.Id; response.perUserRunCount = trigger.perUserRunCount; response.text = trigger.text; response.timeFrom = trigger.timeFrom; response.timeTo = trigger.timeTo; response.type = trigger.type; response.responseStatus = new ResponseStatus (); response.responseStatus.ErrorCode = "200"; response.responseStatus.Message = "SUCCESS"; return response; }