public RescheduleCommand(IEnumerable <IdAndRowVersion> tagIds, int weeks, RescheduledDirection direction, string comment) { Tags = tagIds ?? new List <IdAndRowVersion>(); Weeks = weeks; Direction = direction; Comment = comment; }
public static async Task <IList <IdAndRowVersion> > RescheduleAsync( UserType userType, string plant, IEnumerable <IdAndRowVersion> tagDtos, int weeks, RescheduledDirection direction, string comment, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { Tags = tagDtos, weeks, direction, comment }; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PutAsync($"{_route}/Reschedule", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(null); } var jsonString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <List <IdAndRowVersion> >(jsonString)); }
public void Reschedule(int weeks, RescheduledDirection direction) { if (!HasActivePeriod) { throw new Exception($"{nameof(TagRequirement)} {Id} don't have an active {nameof(PreservationPeriod)}. Can't reschedule"); } NextDueTimeUtc = ActivePeriod.Reschedule(weeks, direction); }
public DateTime Reschedule(int weeks, RescheduledDirection direction) { var rescheduleWeeks = weeks; if (direction == RescheduledDirection.Earlier) { rescheduleWeeks *= -1; } DueTimeUtc = DueTimeUtc.AddWeeks(rescheduleWeeks); return(DueTimeUtc); }
public RescheduledEvent( string plant, Guid objectGuid, int weeks, RescheduledDirection direction, string comment) { Plant = plant; ObjectGuid = objectGuid; Weeks = weeks; Direction = direction; Comment = comment; }