Ejemplo n.º 1
0
        public override Share MapFrom(SqlDataReader @from)
        {
            var shareId  = @from["id"].ToLong();
            var hostId   = @from["host_id"].ToLong();
            var status   = @from["status"].ToInt();
            var startLat = @from["start_latitude"].ToDouble();
            var startLng = @from["start_longitude"].ToDouble();
            var endLat   = @from["end_latitude"].ToDouble();
            var endLng   = @from["end_longitude"].ToDouble();
            var distance = @from["distance"].ToInt();
            var time     = LocalDateTime.Parse(@from["time"].ToString());

            return(new Share()
            {
                Id = shareId,
                Host = _userRepo.GetById(hostId),
                Status = (Status)status,
                Time = time,
                StartLng = startLng,
                StartLat = startLat,
                EndLat = endLat,
                EndLng = endLng,
                SharedDistance = distance
            });
        }
Ejemplo n.º 2
0
        public virtual void ParseDateTimeStandardLocalDateTimeFormat()
        {
            LocalDateTime expected = LocalDateTime.Parse("2017-11-02T15:30");

            SUTime.Time actual = SUTime.ParseDateTime("2017-11-02T15:30", true);
            NUnit.Framework.Assert.AreEqual(expected.ToInstant(ZoneId.SystemDefault().GetRules().GetOffset(expected.ToInstant(ZoneOffset.Utc))).ToEpochMilli(), actual.GetJodaTimeInstant().GetMillis());
        }
Ejemplo n.º 3
0
        public override Company MapFrom(SqlDataReader @from)
        {
            var id           = @from["id"].ToLong();
            var name         = @from["name"].ToString();
            var domain       = @from["domain"].ToString();
            var lat          = @from["latitude"].ToDouble();
            var lng          = @from["longitude"].ToDouble();
            var street       = @from["address"].ToString();
            var region       = @from["region"].ToString();
            var cap          = @from["cap"].ToString();
            var city         = @from["city"].ToString();
            var district     = @from["district"].ToString();
            var registration = LocalDateTime.Parse(@from["registration"].ToString());

            return(new Company()
            {
                Id = id,
                Name = name,
                Address = new Address()
                {
                    Latitude = lat,
                    Longitude = lng,
                    Street = street,
                    Region = region,
                    PostalCode = cap,
                    City = city,
                    District = district
                },
                Domain = domain,
                Registration = registration
            });
        }
Ejemplo n.º 4
0
        /// <summary>Converts a string to a local date time, using the specified
        /// context and culture information.
        /// </summary>
        /// <param name="context">
        /// An System.ComponentModel.ITypeDescriptorContext that provides a format context.
        /// </param>
        /// <param name="culture">
        /// The System.Globalization.CultureInfo to use as the current culture.
        /// </param>
        /// <param name="value">
        /// The System.Object to convert.
        /// </param>
        /// <returns>
        /// An System.Object that represents the converted value.
        /// </returns>
        /// <exception cref="NotSupportedException">
        /// The conversion cannot be performed.
        /// </exception>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var str = value as string;

            if (value == null || str != null)
            {
                return(LocalDateTime.Parse(str, culture));
            }
            return(base.ConvertFrom(context, culture, value));
        }
Ejemplo n.º 5
0
        public void Equals_FormattedAndUnformatted_IsTrue()
        {
            using (new CultureInfoScope("en-GB"))
            {
                var l = LocalDateTime.Parse("14 february 2010", CultureInfo.InvariantCulture);
                var r = LocalDateTime.Parse("2010-02-14", CultureInfo.InvariantCulture);

                Assert.IsTrue(l.Equals(r));
            }
        }
Ejemplo n.º 6
0
 public void Parse_InvalidInput_ThrowsFormatException()
 {
     using (new CultureInfoScope("en-GB"))
     {
         Assert.Catch <FormatException>
             (() =>
         {
             LocalDateTime.Parse("InvalidInput");
         },
             "Not a valid date");
     }
 }
Ejemplo n.º 7
0
        public override ProfileStatus MapFrom(SqlDataReader @from)
        {
            var status = @from["status"].ToString();
            var date   = LocalDateTime.Parse(@from["date"].ToString());
            var hidden = (bool)@from["hidden"];

            return(new ProfileStatus()
            {
                Status = status,
                Date = date,
                Hidden = hidden
            });
        }
Ejemplo n.º 8
0
        public override Message MapFrom(SqlDataReader @from)
        {
            var senderId    = @from["sender_id"].ToLong();
            var sender      = _userRepo.GetById(senderId);
            var messageId   = @from["id"].ToLong();
            var chatId      = @from["chat_id"].ToLong();
            var messageText = @from["text"].ToString();
            var messageTime = LocalDateTime.Parse(@from["time"].ToString());


            var messageNew = (bool)@from["new"];

            return(new Message()
            {
                Id = messageId,
                ChatId = chatId,
                Sender = sender,
                Text = messageText,
                Time = messageTime,
                New = messageNew
            });
        }
Ejemplo n.º 9
0
        public override Chat MapFrom(SqlDataReader @from)
        {
            var userId = @from["userId"].ToLong();
            var user   = _userRepo.GetById(userId);

            var lastMsgSenderId = @from["last_message_sender_id"].ToLong();
            var lastMsgSender   = _userRepo.GetById(lastMsgSenderId);

            var chatId      = @from["id"].ToLong();
            var unreadCount = @from["unread_count"].ToInt();

            var lastMessageId = @from["last_message_id"].ToLong();
            var lastMsgText   = @from["last_message_text"].ToString();


            var lastMsgTime = LocalDateTime.Parse(@from["last_message_time"].ToString());



            var lastMsgNew = (bool)@from["last_message_new"];


            return(new Chat()
            {
                Id = chatId,
                User = user,
                LastMessage = new Message()
                {
                    Id = lastMessageId,
                    Sender = lastMsgSender,
                    Text = lastMsgText,
                    Time = lastMsgTime,
                    New = lastMsgNew
                },
                UnreadCount = unreadCount
            });
        }
Ejemplo n.º 10
0
        public override User MapFrom(SqlDataReader @from)
        {
            var userId    = @from["id"].ToLong();
            var email     = @from["email"].ToString();
            var name      = @from["name"].ToString();
            var surname   = @from["surname"].ToString();
            var companyId = @from["company_id"].ToLong();

            var lat      = @from["home_latitude"].ToDouble();
            var lng      = @from["home_longitude"].ToDouble();
            var street   = @from["home_address"].ToString();
            var region   = @from["home_region"].ToString();
            var city     = @from["home_city"].ToString();
            var cap      = @from["home_cap"].ToString();
            var district = @from["home_district"].ToString();

            var jobLat      = @from["job_latitude"].ToDouble();
            var jobLng      = @from["job_longitude"].ToDouble();
            var jobStreet   = @from["job_address"].ToString();
            var jobRegion   = @from["job_region"].ToString();
            var jobCity     = @from["job_city"].ToString();
            var jobCap      = @from["job_cap"].ToString();
            var jobDistrict = @from["job_district"].ToString();


            var jobStartString = @from["job_start_time"].ToString();
            var jobEndString   = @from["job_end_time"].ToString();

            TimeSpan?jobStartTime;
            TimeSpan?jobEndtime;

            if (jobStartString.Equals(""))
            {
                jobStartTime = null;
            }
            else
            {
                jobStartTime = TimeSpan.Parse(jobStartString);
            }

            if (jobEndString.Equals(""))
            {
                jobEndtime = null;
            }
            else
            {
                jobEndtime = TimeSpan.Parse(jobEndString);
            }


            var      birthdayString = @from["birthday"].ToString();
            DateTime?birthday;

            if (birthdayString.Equals(""))
            {
                birthday = null;
            }
            else
            {
                birthday = LocalDateTime.Parse(birthdayString);
            }


            var regdate = LocalDateTime.Parse(@from["registration_date"].ToString());

            var firebaseToken = @from["firebase_token"].ToString();

            var company = _companyRepo.GetById(companyId);

            return(new User()
            {
                Id = userId,
                Email = email,
                Name = name,
                Surname = surname,
                Address = new Address()
                {
                    Latitude = lat,
                    Longitude = lng,
                    Street = street,
                    Region = region,
                    City = city,
                    PostalCode = cap,
                    District = district
                },
                JobAddress = new Address()
                {
                    Latitude = jobLat,
                    Longitude = jobLng,
                    Street = jobStreet,
                    Region = jobRegion,
                    City = jobCity,
                    PostalCode = jobCap,
                    District = jobDistrict
                },
                JobStartTime = jobStartTime,
                JobEndTime = jobEndtime,
                Company = company,
                Regdate = regdate,
                Birthday = birthday,
                FirebaseToken = firebaseToken
            });
        }