public static WagonInternalOperation SetOpenOperation(this WagonInternalRoutes wir, int id_operation, DateTime date_start, int?id_condition, int?id_loading_status, string locomotive1, string locomotive2, string note, string user) { WagonInternalOperation wio_new = null; if (wir != null && wir.close == null) { WagonInternalOperation wio_last = wir.GetLastOperation(); wio_new = new WagonInternalOperation() { id = 0, id_operation = id_operation, operation_start = date_start, id_condition = (id_condition != null ? (int)id_condition : (wio_last != null ? wio_last.id_condition : 0)), id_loading_status = (id_loading_status != null ? (int)id_loading_status : (wio_last != null ? wio_last.id_loading_status : 0)), locomotive1 = locomotive1, locomotive2 = locomotive2, note = note, create = DateTime.Now, create_user = user, parent_id = wio_last.CloseOperation(date_start, null, user) }; wir.WagonInternalOperation.Add(wio_new); } return(wio_new); }
public static long?CloseWagon(this WagonInternalRoutes wir, DateTime date_end, string note, string user) { if (wir == null) { return(null); } if (wir.close == null) { wir.note = note != null ? note : wir.note; wir.close = DateTime.Now; wir.close_user = user; wir.GetLastMovement().CloseMovement(date_end, note, user); wir.GetLastOperation().CloseOperation(date_end, note, user); // Далее добавить закрытие перемещений по требованию } return(wir.id); }
/// <summary> /// Вагон на территории АМКР с операцией предявлен? /// </summary> /// <param name="context"></param> /// <param name="num"></param> /// <returns></returns> public static bool?isLockPresentOperation(this EFDbContext context, int num) { WagonInternalRoutes wir = context.GetLastWagon(num); if (wir == null) { return(null); } if (wir.close == null) { WagonInternalOperation wio = wir.GetLastOperation(); if (wio == null) { return(null); } return(wio.id_operation == 9 ? true : false); } else { return(false); } }