|
@@ -59,7 +59,7 @@ namespace RaspisKusach
|
|
{
|
|
{
|
|
int availableSeat = -1;
|
|
int availableSeat = -1;
|
|
|
|
|
|
- if(GetCountAvailableSeats(carriage) > 0)
|
|
|
|
|
|
+ if (GetCountAvailableSeats(carriage) > 0)
|
|
{
|
|
{
|
|
if (cnt.db.Tickets.Where(item => item.IdCarriage == carriage.IdCarriage).Select(item => item.PlaceNumber).DefaultIfEmpty(0).Max() + 1 <= carriage.Places)
|
|
if (cnt.db.Tickets.Where(item => item.IdCarriage == carriage.IdCarriage).Select(item => item.PlaceNumber).DefaultIfEmpty(0).Max() + 1 <= carriage.Places)
|
|
availableSeat = cnt.db.Tickets.Where(item => item.IdCarriage == carriage.IdCarriage).Select(item => item.PlaceNumber).DefaultIfEmpty(0).Max() + 1;
|
|
availableSeat = cnt.db.Tickets.Where(item => item.IdCarriage == carriage.IdCarriage).Select(item => item.PlaceNumber).DefaultIfEmpty(0).Max() + 1;
|
|
@@ -85,7 +85,7 @@ namespace RaspisKusach
|
|
Carriages requiredСarriage = cnt.db.Carriages.Where(item => item.IdCarriage == ticket.IdCarriage).FirstOrDefault();
|
|
Carriages requiredСarriage = cnt.db.Carriages.Where(item => item.IdCarriage == ticket.IdCarriage).FirstOrDefault();
|
|
int carrNum = 2;
|
|
int carrNum = 2;
|
|
|
|
|
|
- foreach(Carriages item in cnt.db.Carriages.Where(item => item.IdTrain == ticket.Trips.IdTrain))
|
|
|
|
|
|
+ foreach (Carriages item in cnt.db.Carriages.Where(item => item.IdTrain == ticket.Trips.IdTrain))
|
|
{
|
|
{
|
|
if (item == requiredСarriage)
|
|
if (item == requiredСarriage)
|
|
return carrNum;
|
|
return carrNum;
|
|
@@ -120,7 +120,7 @@ namespace RaspisKusach
|
|
{
|
|
{
|
|
if (str.Length != 5)
|
|
if (str.Length != 5)
|
|
return false;
|
|
return false;
|
|
- for (int i = 0;i<str.Length;i++)
|
|
|
|
|
|
+ for (int i = 0; i < str.Length; i++)
|
|
if (!char.IsDigit(str[i]) && i != 2)
|
|
if (!char.IsDigit(str[i]) && i != 2)
|
|
return false;
|
|
return false;
|
|
if (str[2] != ' ' && str[2] != ':')
|
|
if (str[2] != ' ' && str[2] != ':')
|
|
@@ -169,7 +169,7 @@ namespace RaspisKusach
|
|
// Преобразует из "string" в "String"
|
|
// Преобразует из "string" в "String"
|
|
public static string ToUlower(string str)
|
|
public static string ToUlower(string str)
|
|
{
|
|
{
|
|
- return str.Substring(0, 1).ToUpper() + str.Substring(1, str.Length-1);
|
|
|
|
|
|
+ return str.Substring(0, 1).ToUpper() + str.Substring(1, str.Length - 1);
|
|
}
|
|
}
|
|
// Получение всех станций в маршруте в виде строки
|
|
// Получение всех станций в маршруте в виде строки
|
|
public static string GetAllStations(Routes route)
|
|
public static string GetAllStations(Routes route)
|
|
@@ -186,6 +186,12 @@ namespace RaspisKusach
|
|
return cnt.db.Users.Select(item => item.PhoneNum).Contains(Phone);
|
|
return cnt.db.Users.Select(item => item.PhoneNum).Contains(Phone);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Перевод строки в TimeSpan
|
|
|
|
+ public static TimeSpan GetHHMMTimeSpanFromString(string str)
|
|
|
|
+ {
|
|
|
|
+ return new TimeSpan(Convert.ToInt32(str.Substring(0, 2)), Convert.ToInt32(str.Substring(3, 2)), 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
//Кодирование картинки
|
|
//Кодирование картинки
|
|
public static byte[] BitmapSourceToByteArray(BitmapSource image)
|
|
public static byte[] BitmapSourceToByteArray(BitmapSource image)
|
|
{
|
|
{
|