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


C# ServiceResponse.ObjectToJson方法代码示例

本文整理汇总了C#中ServiceResponse.ObjectToJson方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceResponse.ObjectToJson方法的具体用法?C# ServiceResponse.ObjectToJson怎么用?C# ServiceResponse.ObjectToJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ServiceResponse的用法示例。


在下文中一共展示了ServiceResponse.ObjectToJson方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: CreateSessionRegistration

        public HttpResponseMessage CreateSessionRegistration(SessionRegistrationInfo registration)
        {
            try
            {
                SessionRegistrationDataAccess.CreateItem(registration);

                var savedRegistration = SessionRegistrationDataAccess.GetItems(registration.SessionId).FirstOrDefault(r => r.RegistrationId == registration.RegistrationId);

                var response = new ServiceResponse<SessionRegistrationInfo> { Content = savedRegistration };

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:18,代码来源:SessionRegistrationController.cs

示例5: CreateVolunteer

        public HttpResponseMessage CreateVolunteer(VolunteerInfo volunteer)
        {
            try
            {
                VolunteerDataAccess.CreateItem(volunteer);

                var savedVolunteer = VolunteerDataAccess.GetItemByRegistrationId(volunteer.RegistrationId, volunteer.CodeCampId);

                var response = new ServiceResponse<VolunteerInfo> { Content = savedVolunteer };

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:18,代码来源:VolunteerController.cs

示例6: CreateSessionSpeaker

        public HttpResponseMessage CreateSessionSpeaker(SessionSpeakerInfo speaker)
        {
            try
            {
                SessionSpeakerDataAccess.CreateItem(speaker);

                var sessionSpeakers = SessionSpeakerDataAccess.GetItems(speaker.SessionId);

                var sessionSpeaker =
                    sessionSpeakers.OrderByDescending(s => s.SessionSpeakerId).FirstOrDefault(s => s.SpeakerId == speaker.SpeakerId);

                var response = new ServiceResponse<SessionSpeakerInfo> { Content = sessionSpeaker };

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:21,代码来源:SessionSpeakerController.cs

示例7: AssignSessionToTrack

        public HttpResponseMessage AssignSessionToTrack(int sessionId, int trackId, int codeCampId)
        {
            try
            {
                var session = SessionDataAccess.GetItem(sessionId, codeCampId);

                session.TrackId = trackId;

                session.LastUpdatedByDate = DateTime.Now;
                session.LastUpdatedByUserId = UserInfo.UserID;

                SessionDataAccess.UpdateItem(session);

                var response = new ServiceResponse<string> { Content = SUCCESS_MESSAGE };

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:23,代码来源:SessionController.cs

示例8: CreateRoom

        public HttpResponseMessage CreateRoom(RoomInfo room)
        {
            try
            {
                room.CreatedByDate = DateTime.Now;
                room.CreatedByUserId = UserInfo.UserID;
                room.LastUpdatedByDate = DateTime.Now;
                room.LastUpdatedByUserId = UserInfo.UserID;

                RoomDataAccess.CreateItem(room);

                var savedRoom = RoomDataAccess.GetItems(room.CodeCampId).OrderByDescending(r => r.CreatedByDate).FirstOrDefault();

                var response = new ServiceResponse<RoomInfo> { Content = savedRoom };

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:23,代码来源:RoomController.cs

示例9: DeleteRoom

        public HttpResponseMessage DeleteRoom(int itemId, int codeCampId)
        {
            try
            {
                var tracks = TrackDataAccess.GetItems(codeCampId).Where(t => t.RoomId == itemId);

                if (tracks.Any())
                {
                    foreach (var track in tracks)
                    {
                        track.RoomId = null;
                        track.LastUpdatedByDate = DateTime.Now;
                        track.LastUpdatedByUserId = UserInfo.UserID;

                        TrackDataAccess.UpdateItem(track);
                    }
                }

                RoomDataAccess.DeleteItem(itemId, codeCampId);

                var response = new ServiceResponse<string> { Content = SUCCESS_MESSAGE };

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:30,代码来源:RoomController.cs

示例10: GetSessionRegistrations

        public HttpResponseMessage GetSessionRegistrations(int sessionId)
        {
            try
            {
                var registrations = SessionRegistrationDataAccess.GetItems(sessionId);
                var response = new ServiceResponse<List<SessionRegistrationInfo>> { Content = registrations.ToList() };

                if (registrations == null)
                {
                    ServiceResponseHelper<List<SessionRegistrationInfo>>.AddNoneFoundError("registrations", 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,代码行数:20,代码来源:SessionRegistrationController.cs

示例11: UpdateRoom

        public HttpResponseMessage UpdateRoom(RoomInfo room)
        {
            try
            {
                var originalRoom = RoomDataAccess.GetItem(room.RoomId, room.CodeCampId);
                var updatesToProcess = false;

                if (!string.Equals(originalRoom.RoomName, room.RoomName))
                {
                    originalRoom.RoomName = room.RoomName;
                    updatesToProcess = true;
                }

                if (!string.Equals(originalRoom.Description, room.Description))
                {
                    originalRoom.Description = room.Description;
                    updatesToProcess = true;
                }

                if (originalRoom.MaximumCapacity != room.MaximumCapacity)
                {
                    originalRoom.MaximumCapacity = room.MaximumCapacity;
                    updatesToProcess = true;
                }

                if (updatesToProcess)
                {
                    room.LastUpdatedByDate = DateTime.Now;
                    room.LastUpdatedByUserId = UserInfo.UserID;

                    RoomDataAccess.UpdateItem(room);
                }

                var savedRoom = RoomDataAccess.GetItem(room.RoomId, room.CodeCampId);

                var response = new ServiceResponse<RoomInfo> { Content = savedRoom };

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:45,代码来源:RoomController.cs

示例12: DeleteSpeaker

        public HttpResponseMessage DeleteSpeaker(int itemId, int codeCampId)
        {
            try
            {
                SpeakerDataAccess.DeleteItem(itemId, codeCampId);

                var response = new ServiceResponse<string> { Content = SUCCESS_MESSAGE };

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
开发者ID:hismightiness,项目名称:dnnextensions,代码行数:16,代码来源:SpeakerController.cs

示例13: UpdateSpeaker


//.........这里部分代码省略.........
                {
                    var fileData = Convert.FromBase64String(speaker.AvatarDataURIData);

                    // get the folder from the API
                    var folderInfo = FolderManager.Instance.GetFolder(
                        portalId: portalId,
                        folderPath: string.Format(Globals.SPEAKER_AVATAR_FOLDER_PATH_FORMAT, speaker.CodeCampId));

                    if (folderInfo == null)
                    {
                        // add the folder since it doesn't yet exist
                        folderInfo = FolderManager.Instance.AddFolder(
                            portalId: portalId,
                            folderPath: string.Format(Globals.SPEAKER_AVATAR_FOLDER_PATH_FORMAT, speaker.CodeCampId));
                    }

                    IFileInfo fileInfo = null;
                    using (var reader = new MemoryStream(fileData))
                    {
                        var filename = string.Format(Globals.SPEAKER_AVATAR_FILENAME_FORMAT, speaker.SpeakerId,
                            DateTime.Now.ToString(Globals.SPEAKER_AVATAR_FILENAME_STAMP_FORMAT),
                            Globals.SPEAKER_AVATAR_FILEEXTENSION);

                        fileInfo = FileManager.Instance.AddFile(folderInfo, filename, reader, true);
                        speaker.IconFile = string.Format(Globals.SPEAKER_ICON_FILE_PATH, portalId, fileInfo.RelativePath);
                        originalSpeaker.IconFile = speaker.IconFile;
                    }

                    updatesToProcess = true;
                }

                if (speaker.RemoveAvatar)
                {
                    speaker.IconFile = string.Empty;
                    originalSpeaker.IconFile = speaker.IconFile;
                    updatesToProcess = true;
                }

                if (originalSpeaker.CustomProperties != null)
                {
                    // parse custom properties for updates
                    foreach (var property in originalSpeaker.CustomPropertiesObj)
                    {
                        if (speaker.CustomPropertiesObj.Any(p => p.Name == property.Name))
                        {
                            // see if the existing property needs to be updated
                            var prop = speaker.CustomPropertiesObj.FirstOrDefault(p => p.Name == property.Name);
                            if (!string.Equals(prop.Value, property.Value))
                            {
                                property.Value = prop.Value;
                                updatesToProcess = true;
                            }
                        }
                        else
                        {
                            // delete the property
                            originalSpeaker.CustomPropertiesObj.Remove(property);
                            updatesToProcess = true;
                        }
                    }
                }

                if (speaker.CustomPropertiesObj != null)
                {
                    // add any new properties
                    if (originalSpeaker.CustomProperties == null)
                    {
                        foreach (var property in speaker.CustomPropertiesObj)
                        {
                            originalSpeaker.CustomPropertiesObj.Add(property);
                            updatesToProcess = true;
                        }
                    }
                    else
                    {
                        foreach (var property in speaker.CustomPropertiesObj.Where(property => !originalSpeaker.CustomPropertiesObj.Contains(property)))
                        {
                            originalSpeaker.CustomPropertiesObj.Add(property);
                            updatesToProcess = true;
                        }
                    }
                }

                if (updatesToProcess)
                {
                    SpeakerDataAccess.UpdateItem(originalSpeaker);
                }

                var savedSpeaker = SpeakerDataAccess.GetItem(speaker.SpeakerId, speaker.CodeCampId);

                var response = new ServiceResponse<SpeakerInfo> { Content = savedSpeaker };

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
开发者ID:hismightiness,项目名称:dnnextensions,代码行数:101,代码来源:SpeakerController.cs

示例14: UpdateTimeSlot

        public HttpResponseMessage UpdateTimeSlot(TimeSlotInfo timeSlot)
        {
            try
            {
                var updatesToProcess = false;
                var originalTimeSlot = TimeSlotDataAccess.GetItem(timeSlot.TimeSlotId, timeSlot.CodeCampId);

                updatesToProcess = TimeSlotHasUpdates(ref originalTimeSlot, ref timeSlot);

                if (updatesToProcess)
                {
                    originalTimeSlot.LastUpdatedByDate = DateTime.Now;
                    originalTimeSlot.LastUpdatedByUserId = UserInfo.UserID;

                    TimeSlotDataAccess.UpdateItem(originalTimeSlot);
                }

                var savedTimeSlot = TimeSlotDataAccess.GetItem(timeSlot.TimeSlotId, timeSlot.CodeCampId);

                // removing this prevented the saved/retrieved time from being offset to being about 4 hours off
                //if (savedTimeSlot != null)
                //{
                //    savedTimeSlot.BeginTime = savedTimeSlot.BeginTime.ToLocalTime();
                //    savedTimeSlot.EndTime = savedTimeSlot.EndTime.ToLocalTime();
                //}

                var response = new ServiceResponse<TimeSlotInfo> { Content = savedTimeSlot };

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:36,代码来源:TimeSlotController.cs

示例15: UpdateRegistration

        public HttpResponseMessage UpdateRegistration(RegistrationInfo registration)
        {
            try
            {
                var originalRegistration = RegistrationDataAccess.GetItemByUserId(registration.UserId, registration.CodeCampId);
                var updatesToProcess = false;

                // only update the fields that would be udpdated from the UI to keep the DB clean

                if (originalRegistration.ShirtSize != registration.ShirtSize)
                {
                    originalRegistration.ShirtSize = registration.ShirtSize;
                    updatesToProcess = true;
                }

                if (originalRegistration.HasDietaryRequirements != registration.HasDietaryRequirements)
                {
                    originalRegistration.HasDietaryRequirements = registration.HasDietaryRequirements;
                    updatesToProcess = true;
                }

                if (originalRegistration.Notes != registration.Notes)
                {
                    originalRegistration.Notes = registration.Notes;
                    updatesToProcess = true;
                }

                if (originalRegistration.CustomProperties != null)
                {
                    // parse custom properties for updates
                    foreach (var property in originalRegistration.CustomPropertiesObj)
                    {
                        if (registration.CustomPropertiesObj.Any(p => p.Name == property.Name))
                        {
                            // see if the existing property needs to be updated
                            var prop = registration.CustomPropertiesObj.FirstOrDefault(p => p.Name == property.Name);
                            if (!string.Equals(prop.Value, property.Value))
                            {
                                property.Value = prop.Value;
                                updatesToProcess = true;
                            }
                        }
                        else
                        {
                            // delete the property
                            originalRegistration.CustomPropertiesObj.Remove(property);
                            updatesToProcess = true;
                        }
                    }
                }

                if (registration.CustomPropertiesObj != null)
                {
                    // add any new properties
                    if (originalRegistration.CustomProperties == null)
                    {
                        foreach (var property in registration.CustomPropertiesObj)
                        {
                            originalRegistration.CustomPropertiesObj.Add(property);
                            updatesToProcess = true;
                        }
                    }
                    else
                    {
                        foreach (var property in registration.CustomPropertiesObj.Where(property => !originalRegistration.CustomPropertiesObj.Contains(property)))
                        {
                            originalRegistration.CustomPropertiesObj.Add(property);
                            updatesToProcess = true;
                        }
                    }
                }

                if (updatesToProcess)
                {
                    RegistrationDataAccess.UpdateItem(originalRegistration);
                }

                var response = new ServiceResponse<string> { Content = SUCCESS_MESSAGE };

                return Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson());
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE);
            }
        }
开发者ID:nvisionative,项目名称:dnnextensions,代码行数:87,代码来源:RegistrationController.cs


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