当前位置: 首页>>代码示例>>C#>>正文


C# ServiceResponse类代码示例

本文整理汇总了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);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:28,代码来源:VolunteerTaskController.cs

示例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;
        }
开发者ID:RabidDog,项目名称:myfinfriend,代码行数:30,代码来源:DefaultSearchEngine.cs

示例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;
        }
开发者ID:balachandarj,项目名称:theranos,代码行数:34,代码来源:ReservationBL.cs

示例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);
        }
开发者ID:chlowell,项目名称:dotnet-apiport,代码行数:7,代码来源:FileOutputApiPortService.cs

示例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);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:30,代码来源:TrackController.cs

示例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;
        }
开发者ID:ChenKKaminsky,项目名称:Route-Planner,代码行数:25,代码来源:GoogleMapsApi.cs

示例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;
        }
开发者ID:ChenKKaminsky,项目名称:Route-Planner,代码行数:33,代码来源:DistanceMatrixApi.cs

示例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);
        }
开发者ID:programulya,项目名称:Contacts,代码行数:30,代码来源:HomeController.cs

示例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;
            }
        }
开发者ID:grantcolley,项目名称:authorisationmanager,代码行数:28,代码来源:AuthorisationManagerWCFClient.cs

示例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);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:30,代码来源:TimeSlotController.cs

示例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;
 }
开发者ID:chrcar01,项目名称:SimpleTasks,代码行数:8,代码来源:SecurityService.cs

示例12: GetEvent

        public ServiceResponse<CodeCampInfo> GetEvent(int itemId)
        {
            var result = new ServiceResponse<CodeCampInfo>();

            result = ServiceHelper.GetRequest<ServiceResponse<CodeCampInfo>>(fullApiUri + "GetEvent?itemId=" + itemId);

            return result;
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:8,代码来源:ServiceProxy.cs

示例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;
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:8,代码来源:ServiceProxy.cs

示例14: CreateEvent

        public ServiceResponse<string> CreateEvent(CodeCampInfo codeCamp)
        {
            var result = new ServiceResponse<string>();

            result = ServiceHelper.PostRequest<ServiceResponse<string>>(fullApiUri + "CreateEvent", codeCamp.ObjectToJson());

            return result;
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:8,代码来源:ServiceProxy.cs

示例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;
 }
开发者ID:chrcar01,项目名称:SimpleTasks,代码行数:10,代码来源:SecurityService.cs


注:本文中的ServiceResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。