public bool Update(MasterCourse masterCourse) { IRestRequest request = new RestRequest("/api/mastercourse", Method.PUT); request.AddParameter("application/json; charset=utf-8", JsonConvert.SerializeObject(masterCourse), ParameterType.RequestBody); request.RequestFormat = DataFormat.Json; IRestResponse response = Client.Execute(request); if (response.StatusCode == System.Net.HttpStatusCode.OK) return true; else { this.setError(response); return false; } }
public Guid Create(MasterCourse masterCourse) { IRestRequest request = new RestRequest("/api/mastercourse", Method.POST); request.AddParameter("application/json; charset=utf-8", JsonConvert.SerializeObject(masterCourse), ParameterType.RequestBody); request.RequestFormat = DataFormat.Json; IRestResponse response = Client.Post<MasterCourse>(request); Guid guid = Guid.Empty; if (response.StatusCode == System.Net.HttpStatusCode.OK) { Guid.TryParse(Newtonsoft.Json.JsonConvert.DeserializeObject<ApiObjectId>(response.Content).Id, out guid); } else { this.setError(response); } return guid; }
static void UpdateMasterCourse(Guid masterCourseGuid) { ServiceFactory factory = new ServiceFactory(); IMasterCourseService mcService = factory.CreateMasterCourseService(); var masterCourse = new MasterCourse(); // the following are required fields. masterCourse.MasterCourseGuid = masterCourseGuid; masterCourse.Name = "Test Master Course - Modified"; masterCourse.Programs = null; //Programlarda değişiklik istenmiyorsa bu değer null geçilmeli. // the following are optional fields. masterCourse.Description = "Description"; masterCourse.ShortDescription = "ShortDescription"; masterCourse.Categories = new List<string>(); masterCourse.Audiences = new List<string>(); bool success = mcService.Update(masterCourse); if (!success) { printError(mcService.LastError); } else { Console.WriteLine(string.Format("Name of master course {0} was updated to {1}.", masterCourse.MasterCourseGuid, masterCourse.Name)); } }
static Guid CreateMasterCourse(Guid organizationalUnitGuid) { ServiceFactory factory = new ServiceFactory(); IMasterCourseService mcService = factory.CreateMasterCourseService(); var masterCourse = new MasterCourse(); // the following are required fields. masterCourse.MasterCourseGuid = Guid.Empty; masterCourse.Name = "Test Master Course"; masterCourse.Programs.Add(organizationalUnitGuid); // the following are optional fields. masterCourse.Description = "master course description"; masterCourse.ShortDescription = "ShortDescription"; masterCourse.Categories = new List<string>(); masterCourse.Audiences = new List<string>(); var masterCourseGuid = mcService.Create(masterCourse); if (masterCourseGuid == Guid.Empty) { printError(mcService.LastError); } else { Console.WriteLine(string.Format("Master course {0} was created.", masterCourse.Name)); } return masterCourseGuid; }