本文整理汇总了C#中ServiceResponse类的典型用法代码示例。如果您正苦于以下问题:C# ServiceResponse类的具体用法?C# ServiceResponse怎么用?C# ServiceResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceResponse类属于命名空间,在下文中一共展示了ServiceResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateVolunteerTask
public HttpResponseMessage CreateVolunteerTask(VolunteerTaskInfo task)
{
try
{
var timeStamp = DateTime.Now;
task.CreatedByDate = timeStamp;
task.CreatedByUserId = UserInfo.UserID;
task.LastUpdatedByDate = timeStamp;
task.LastUpdatedByUserId = UserInfo.UserID;
VolunteerTaskDataAccess.CreateItem(task);
var savedTask =
VolunteerTaskDataAccess.GetItems(task.VolunteerId)
.OrderByDescending(t => t.CreatedByDate)
.FirstOrDefault();
var response = new ServiceResponse<VolunteerTaskInfo> { Content = savedTask };
return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
}
catch (Exception ex)
{
Exceptions.LogException(ex);
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
}
}
示例2: using
ServiceResponse<IList<BudgetReceipt>> ISearchEngine.FindBudgetItemDescriptions(ServiceRequest<BudgetReceipt> searchRequest)
{
var output = new ServiceResponse<IList<BudgetReceipt>>();
using (var unitOfWork = RepositoryManager<BudgetReceipt>.Instance.CreateWorkUnit())
{
try
{
var repo = new Repository<BudgetReceipt>(unitOfWork.Session);
var result = repo.FilterBy(x => (x.Subscriber.Id == _subscriber.Id && x.Description.StartsWith(searchRequest.Data.Description))).ToList();
unitOfWork.Commit();
output.Data = result.Distinct(new BudgetReceipt.DescriptionCompare()).ToList();
output.Result = Result.Successful;
}
catch (GenericADOException e)
{
output.Message = MessageFactory.CreateGenerator(RepositoryType.Postgres).GenerateErrorMessage(e);
_logger.Critical(output.Message, e);
output.Result = Result.Failure;
}
catch (Exception e)
{
_logger.Critical(e.Message, e);
}
}
return output;
}
示例3: BookTableReservation
/// <summary>
/// Book the table reservation
/// </summary>
/// <param name="bookingDetail">Booking detais</param>
/// <returns></returns>
public ServiceResponse<bool> BookTableReservation(BookingDetail bookingDetail)
{
// Add business rules
var serviceResponse = new ServiceResponse<bool>();
try
{
var result = reservationRepository.BookTableReservation(bookingDetail);
serviceResponse.Result = result;
if (result == true)
{
serviceResponse.OperationSuccess = true;
serviceResponse.ServiceMessage = "Booking successful";
}
else
{
serviceResponse.OperationSuccess = false;
serviceResponse.ServiceMessage = "Unable to book the reservation";
}
}
catch (Exception ex)
{
serviceResponse.ErrorMessage = ex.Message;
}
return serviceResponse;
}
示例4: GetResultFormatsAsync
public Task<ServiceResponse<IEnumerable<ResultFormatInformation>>> GetResultFormatsAsync()
{
var format = new ResultFormatInformation { DisplayName = "Excel", FileExtension = ".xlsx" };
var response = new ServiceResponse<IEnumerable<ResultFormatInformation>>(new[] { format });
return Task.FromResult(response);
}
示例5: AssignRoomToTrack
public HttpResponseMessage AssignRoomToTrack(int roomId, int trackId, int codeCampId)
{
try
{
var track = TrackDataAccess.GetItem(trackId, codeCampId);
if (track != null)
{
track.RoomId = roomId;
track.LastUpdatedByDate = DateTime.Now;
track.LastUpdatedByUserId = UserInfo.UserID;
TrackDataAccess.UpdateItem(track);
}
var response = new ServiceResponse<string> { Content = SUCCESS_MESSAGE };
if (track == null)
{
ServiceResponseHelper<string>.AddNoneFoundError("track", ref response);
}
return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
}
catch (Exception ex)
{
Exceptions.LogException(ex);
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
}
}
示例6: GetResponseAsync
public async Task<ServiceResponse<string>> GetResponseAsync(GoogleMapsParameters parameters)
{
var result = new ServiceResponse<string>()
{
Success = false,
Message = "Failed to get a response from service"
};
var uri = GetUri(parameters);
using (var client = new HttpClient())
{
try
{
result.Value = await client.GetStringAsync(uri);
result.Success = true;
result.Message = "Ok";
}
catch (Exception)
{
throw;
}
}
return result;
}
示例7: GetAddressInfoAsync
public async Task<ServiceResponse<int>> GetAddressInfoAsync(DistanceMatrixParameters parameters, InfoType info)
{
var result = new ServiceResponse<int>()
{
Success = false,
Message = "Failed to get Buration data from service"
};
var response = await GetResponseAsync(parameters);
if (response.Success)
{
var json = JsonConvert.DeserializeObject<DistanceMatrixResponse>(response.Value);
var elem = json.Rows[0].Elements[0];
var propName = Enum.GetName(typeof(InfoType), (int)info);
var item = elem.GetType().GetProperty(propName).GetValue(elem);
var value = item.GetType().GetProperty("Value").GetValue(item);
result.Value = (int)value;
result.Success = true;
result.Message = "";
}
else
{
throw new Exception(response.Message, new Exception(response.Value));
}
return result;
}
示例8: AddContact
public JsonResult AddContact(string firstName, string middleName, string lastName, string email, string phone,
int contactGroupId)
{
var result = new ServiceResponse<Object>();
var contact = new Contact
{
FirstName = firstName,
MiddleName = middleName,
LastName = lastName,
Email = email,
Phone = phone,
ContactGroupId = contactGroupId
};
try
{
_contactService.AddContact(contact);
}
catch (Exception ex)
{
Trace.WriteLine("AddContact: " + ex.Message);
result.Message = ex.Message;
}
result.Result = GetAllGroupsResponse();
return JsonResponse(result);
}
示例9: SaveActivity
public async Task<string> SaveActivity(string activity)
{
WCFProxy.AuthorisationManagerServiceClient authorisationManagerServiceClient = null;
try
{
authorisationManagerServiceClient
= new WCFProxy.AuthorisationManagerServiceClient(new WSHttpBinding(),
new EndpointAddress(endpointAddress));
var result = await authorisationManagerServiceClient.SaveActivityAsync(activity).ConfigureAwait(false);
authorisationManagerServiceClient.Close();
return result;
}
catch (Exception ex)
{
if (authorisationManagerServiceClient != null)
{
authorisationManagerServiceClient.Abort();
}
var serviceResponse = new ServiceResponse(ex.Message, true);
var response = Serializer.SerializeToJson(serviceResponse);
return response;
}
}
示例10: AssignSessionToTimeSlot
public HttpResponseMessage AssignSessionToTimeSlot(int sessionId, int timeSlotId, int codeCampId)
{
try
{
var session = SessionDataAccess.GetItem(sessionId, codeCampId);
if (session != null)
{
session.TimeSlotId = timeSlotId;
session.LastUpdatedByDate = DateTime.Now;
session.LastUpdatedByUserId = UserInfo.UserID;
SessionDataAccess.UpdateItem(session);
}
var response = new ServiceResponse<string> { Content = SUCCESS_MESSAGE };
if (session == null)
{
ServiceResponseHelper<string>.AddNoneFoundError("session", ref response);
}
return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
}
catch (Exception ex)
{
Exceptions.LogException(ex);
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
}
}
示例11: CreateMember
public ServiceResponse CreateMember(Member member, string originalPassword)
{
var result = new ServiceResponse();
member.PasswordSalt = CreateSalt();
member.HashedPassword = _formsAuth.HashPasswordForStoringInConfigFile(originalPassword + member.PasswordSalt, "sha1");
_memberRepo.Save(member);
return result;
}
示例12: GetEvent
public ServiceResponse<CodeCampInfo> GetEvent(int itemId)
{
var result = new ServiceResponse<CodeCampInfo>();
result = ServiceHelper.GetRequest<ServiceResponse<CodeCampInfo>>(fullApiUri + "GetEvent?itemId=" + itemId);
return result;
}
示例13: DeleteEvent
public ServiceResponse<string> DeleteEvent(int itemId)
{
var result = new ServiceResponse<string>();
result = ServiceHelper.DeleteRequest<ServiceResponse<string>>(fullApiUri + "DeleteEvent?itemId=" + itemId, string.Empty);
return result;
}
示例14: CreateEvent
public ServiceResponse<string> CreateEvent(CodeCampInfo codeCamp)
{
var result = new ServiceResponse<string>();
result = ServiceHelper.PostRequest<ServiceResponse<string>>(fullApiUri + "CreateEvent", codeCamp.ObjectToJson());
return result;
}
示例15: Login
public ServiceResponse<LoginResult> Login(string email, string password)
{
var result = new ServiceResponse<LoginResult>();
var member = GetMember(email, password);
var loginResult = new LoginResult();
loginResult.LoginFailed = member == null;
loginResult.Member = member;
result.Data = loginResult;
return result;
}