public HttpResponseMessage PostClimberCollection(APISignedRequest request) { CompetitionModel comp; var climberCollection = GetRequestParameter <API_ClimbersCollection>(request, out comp); List <Comp_CompetitiorRegistrationModel> addedClimbers = new List <Comp_CompetitiorRegistrationModel>(); foreach (var newClm in climberCollection.Data) { addedClimbers.Add(SaveOneClimber(newClm, comp)); } db.SaveChanges(); bool hasLock = false; try { Monitor.Enter(ApplicationsController.APPLICATIONS_LOCKER, ref hasLock); HashSet <long> newClimbers = new HashSet <long>(addedClimbers.Select(c => c.Iid)); var toRemove = comp.Climbers.ToList().Where(c => !newClimbers.Contains(c.Iid)).ToArray(); for (int i = 0; i < toRemove.Length; i++) { foreach (var result in toRemove[i].Results.ToArray()) { db.Results.Remove(result); } db.CompetitionClimbers.Remove(toRemove[i]); } db.SaveChanges(); } finally { if (hasLock) { Monitor.Exit(ApplicationsController.APPLICATIONS_LOCKER); } } var res = new API_ClimbersCollection { Data = addedClimbers.Select(c => c.ToApi(true)).ToArray() }; return(Request.CreateResponse <API_ClimbersCollection>(HttpStatusCode.Created, res)); }
public AsyncRequestResult BeginPostClimberCollection(API_ClimbersCollection climbers, RequestCompleted <API_ClimbersCollection> callback, Object asyncState) { return(BeginPostSerializableT("Calendar", "PostClimberCollection", String.Empty, climbers, callback, asyncState, true)); }
public API_ClimbersCollection PostClimberCollection(API_ClimbersCollection climbers) { return(PostSerializableT("Calendar", "PostClimberCollection", String.Empty, climbers)); }