Example #1
0
        public bool UpdateDispatcherFareFailded(long id, FareStatus status, string comment, out string report)
        {
            report = string.Empty;
            bool retVal = false;

            try
            {
                var fare = DataManager.DataManager.Instance.GetById <Model.Fare>(id);

                if (fare != null)
                {
                    fare.FareStatus = status;

                    Model.Comment fareComment;
                    if (fare.Comment != 0)
                    {
                        fareComment = DataManager.DataManager.Instance.GetById <Model.Comment>(fare.Comment);
                        if (fareComment != null)
                        {
                            fareComment.Description   = comment;
                            fareComment.DateOfPublish = DateTime.Now;
                            DataManager.DataManager.Instance.UpdateEntity <Model.Comment>(fareComment);
                        }
                    }
                    else
                    {
                        fareComment      = new Model.Comment(comment);
                        fareComment.Fare = fare.Id;
                        fare.Comment     = fareComment.Id;
                        DataManager.DataManager.Instance.AddNewEntity <Model.Comment>(fareComment);
                        //DataManager.DataManager.Instance.UpdateEntity<Model.Fare>(fare);
                    }


                    DataManager.DataManager.Instance.UpdateEntity <Model.Fare>(fare);
                }
                retVal = false;
            }
            catch (Exception ex)
            {
                report = ex.Message;
                retVal = false;
            }
            return(retVal);
        }
Example #2
0
        public bool UpdateCustomerFare(long id,
                                       double locX, double locY,
                                       string addrStreet, int addrNumber, string addrCity, int addrPostalCode,
                                       int type, DateTime date, FareStatus status, string comment, out string report)
        {
            report = string.Empty;
            bool retVal = false;

            try
            {
                var fare = DataManager.DataManager.Instance.GetById <Model.Fare>(id);
                if (fare != null)
                {
                    fare.FareStatus         = status;
                    fare.DesiredVehicleType = (VehicleType)type;
                    fare.DateOfDrive        = date;
                    Model.Comment fareComment;
                    if (fare.Comment != 0)
                    {
                        fareComment = DataManager.DataManager.Instance.GetById <Model.Comment>(fare.Comment);
                        if (fareComment != null)
                        {
                            fareComment.Description   = comment;
                            fareComment.DateOfPublish = DateTime.Now;
                            DataManager.DataManager.Instance.UpdateEntity <Model.Comment>(fareComment);
                        }
                    }
                    else
                    {
                        fareComment      = new Model.Comment(comment);
                        fareComment.Fare = fare.Id;
                        fare.Comment     = fareComment.Id;
                        DataManager.DataManager.Instance.AddNewEntity <Model.Comment>(fareComment);
                        DataManager.DataManager.Instance.UpdateEntity <Model.Fare>(fare);
                    }

                    var location = DataManager.DataManager.Instance.GetById <Model.Location>(fare.StartLocation);
                    if (location != null)
                    {
                        location.X = locX;
                        location.Y = locY;
                        DataManager.DataManager.Instance.UpdateEntity <Model.Location>(location);
                        var address = DataManager.DataManager.Instance.GetById <Model.Address>(location.Address);
                        if (address != null)
                        {
                            address.Street     = addrStreet;
                            address.Number     = addrNumber;
                            address.PostalCode = addrPostalCode;
                            address.City       = addrCity;
                            DataManager.DataManager.Instance.UpdateEntity <Model.Address>(address);
                        }
                    }
                    DataManager.DataManager.Instance.UpdateEntity <Model.Fare>(fare);
                    retVal = true;
                }
            }
            catch (Exception ex)
            {
                report = ex.Message;
                retVal = false;
            }
            return(retVal);
        }