Ejemplo n.º 1
0
        /// <summary>
        /// Закрывает сессию.
        /// </summary>
        public static void CloseSession(RentSession session)
        {
            var ds = (SQLDataService)DataServiceProvider.DataService;

            if (session.FinalBicycleState.Equals(BicycleState.Украден))
            {
                session.EmployeeTake = null;
                session.EndPoint     = null;
                session.FinishDate   = null;
                session.Cost         = 0;
                session.SessionState = SessionState.Закрыта;
            }
            else
            {
                session.FinishDate = DateTime.Now;
                session.Cost       = System.Math.Round((session.FinishDate.Value - session.StartDate)
                                                       .TotalMinutes) * session.Bicycle.CostPerMinute;
                session.SessionState = SessionState.Закрыта;
            }

            var bicycle = new Bicycle();

            bicycle.SetExistObjectPrimaryKey(session.Bicycle.__PrimaryKey);
            ds.LoadObject(bicycle);
            bicycle.State    = session.FinalBicycleState;
            bicycle.CurPoint = session.EndPoint;
            bicycle.IsFree   = true;

            var updObjs = new DataObject[] { session, bicycle };

            ds.UpdateObjects(ref updObjs);
        }
Ejemplo n.º 2
0
        // *** Start programmer edit section *** (RentSession CustomMembers)
        /// <summary>
        /// Обновляет состояние велосипедов после открытия сессии.
        /// </summary>
        public static void UpdateBicycleAfterSessionOpen(RentSession session)
        {
            var ds = (SQLDataService)DataServiceProvider.DataService;

            var bicycle = new Bicycle();

            bicycle.SetExistObjectPrimaryKey(session.Bicycle.__PrimaryKey);
            ds.LoadObject(bicycle);

            bicycle.CurPoint = null;
            bicycle.IsFree   = false;
            ds.UpdateObject(bicycle);
        }