Esempio n. 1
0
        /// <summary>
        /// This method updates a Location and returns true if successful
        /// </summary>
        /// <param name="Location"></param>
        /// <returns></returns>
        public async Task <bool> UpdateLocation(LocationDVM Location)
        {
            bool result = false;

            if (Location != null)
            {
                Location c = await locationRepository.GetAsync(Location.Id);

                if (c != null)
                {
                    c.City       = Location.City;
                    c.Latitude   = Location.Latitude;
                    c.Longitude  = Location.Longitude;
                    c.PostalCode = Location.PostalCode;
                    c.State      = Location.State;

                    try
                    {
                        await locationRepository.UpdateAsync(c);

                        result = true;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// This method gets Location by id
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public async Task <LocationDVM> GetLocationByID(int Id)
        {
            LocationDVM cdvm = new LocationDVM();

            if (Id > 0)
            {
                Location c = await locationRepository.GetAsync(Id);

                if (c != null)
                {
                    cdvm = mapper.Map <LocationDVM>(c);
                }
            }
            return(cdvm);
        }
Esempio n. 3
0
        /// <summary>
        /// This method Adds a new Location and returns the id
        /// </summary>
        /// <param name="Location"></param>
        /// <returns></returns>
        public async Task <int> AddLocation(LocationDVM location)
        {
            int id = 0;

            if (location != null)
            {
                Location c = mapper.Map <Location>(location);
                try
                {
                    var obj = await locationRepository.InsertAsync(c);

                    id = obj.Id;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(id);
        }