Esempio n. 1
0
        public HttpResponseMessage UpdateLocation(string sessionKey, FriendLocation location)
        {
            var dbLocation = ApiToDbModelConverter.Convert(location);

            this.repo.UpdateLocation(sessionKey, dbLocation);

            return this.Request.CreateResponse(HttpStatusCode.OK);
        }
        public static FriendLocation Convert(Location location)
        {
            var apiLocation = new FriendLocation();
            apiLocation.Description = location.Description;
            apiLocation.Lathitude = location.Lathitude;
            apiLocation.Longitude = location.Longitude;
            apiLocation.Year = location.DateAdded.Value.Year.ToString();
            apiLocation.Month = location.DateAdded.Value.Month.ToString();
            apiLocation.Day = location.DateAdded.Value.Day.ToString();
            apiLocation.Time = location.DateAdded.Value.Hour.ToString() + ":" + location.DateAdded.Value.Minute.ToString();

            return apiLocation;
        }
        public static Location Convert(FriendLocation location)
        {
            var dbLocation = new Location();
            dbLocation.Description = location.Description;
            dbLocation.Lathitude = location.Lathitude;
            dbLocation.Longitude = location.Longitude;
            string[] timeComponents = location.Time.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
            dbLocation.DateAdded = new DateTime(int.Parse(location.Year),
                int.Parse(location.Month),
                int.Parse(location.Day),
                int.Parse(timeComponents[0]),
                int.Parse(timeComponents[1]),
                0);

            return dbLocation;
        }