public HttpResponseMessage UpdateLandsDemand(List <Land> lands, HttpRequestMessage <List <Land> > request) { var connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["EarthwatchersConnection"].ConnectionString; var earthwatcher = Session.HasLoggedUser() ? new EarthwatcherRepository(connectionstring).GetEarthwatcher(Session.GetCookieInfo().EarthwatcherName, false) : null; var landsToConfirm = lands.Where(l => l.Reset == null || l.Reset == false).ToList(); var landsToReset = lands.Where(l => l.Reset.HasValue && l.Reset == true).ToList(); try { if (landsToReset.Any()) { landRepository.ForceLandsReset(landsToReset, earthwatcher != null ? earthwatcher.Id : 0); } if (landsToConfirm.Any()) { if (landRepository.UpdateLandsDemand(lands, earthwatcher != null ? earthwatcher.Id : 0)) { //Genero las imágenes ImagesGeneratorTool.Run(landRepository, true, null); //Send notification emails SendEmail_GreenpeaceConfirmation(lands, earthwatcher); } } return(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK }); } catch (Exception ex) { throw new HttpResponseException(ex.Message); } }