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; }
public uint calculate( bool IsRented, Location location, uint AnnualBasicSalary, uint MonthlyRent, uint AnnualHouseRentAllowance) { var taxExemption = default(uint); if (IsRented == false) { return taxExemption; } // Calculate location based allowance var locationAllowance = default(uint); switch (location) { case Location.Metro: locationAllowance = Convert.ToUInt32(Math.Ceiling(0.5 * AnnualBasicSalary)); break; case Location.NonMetro: locationAllowance = Convert.ToUInt32(Math.Ceiling(0.4 * AnnualBasicSalary)); break; default: throw new InvalidLocationException(); } // Calculate default house rent allowance var defaultHRA = 12 * MonthlyRent - Convert.ToUInt32(Math.Ceiling(0.1 * AnnualBasicSalary)); // Calculate the minimum taxExemption = defaultHRA; if (locationAllowance < defaultHRA) { taxExemption = locationAllowance; } if (AnnualHouseRentAllowance < taxExemption) { taxExemption = AnnualHouseRentAllowance; } return taxExemption; }
public uint ReOrder( bool IsExistingContract, Location location, uint TotalOrderValue, uint MonthlyOrders, uint CustomerDiscount) { var orderExemption = default(uint); if (IsExistingContract == false) { return orderExemption; } // Calculate location based delivery costs var locationAllowance = default(uint); switch (location) { case Location.Metro: locationAllowance = Convert.ToUInt32(Math.Ceiling(0.1 * TotalOrderValue)); break; case Location.NonMetro: locationAllowance = Convert.ToUInt32(Math.Ceiling(0.2 * TotalOrderValue)); break; default: throw new InvalidLocationException(); } // Calculate discounts based on orders per month var discount = 12 * MonthlyOrders - Convert.ToUInt32(Math.Ceiling(0.1 * TotalOrderValue)); // Calculate the minimum orderExemption = discount; if (locationAllowance < discount) { orderExemption = locationAllowance; } if (CustomerDiscount < orderExemption) { orderExemption = CustomerDiscount; } return orderExemption; }
public LocationModel Map(Location location) { var address = BuildAddress(location); return new LocationModel { UPRN = location.UPRN.ToString(), AddressLines = address, OrganisationName = location.OrganisationName, BuildingName = location.BuildingName, HouseNumber = location.HouseNumber, StreetDescription = location.StreetDescription, Locality = location.Locality, TownName = location.TownName, AdministrativeArea = location.AdministrativeArea, PostTown = location.PostalTown, Postcode = location.PostCode, PostcodeLocator = location.PostcodeLocator, Coordinate = new CoordinateModel(location.XCoordinate, location.YCoordinate) }; }
public IEnumerable<Poll> GetAvailablePollsForAnswer(Location location, User currentUser) { return this.catalog.Polls.RetrievePollsAvailableForAnswer(location, currentUser); }
private IEnumerable<string> BuildAddress(Location location) { var result = new List<string>(); if (!string.IsNullOrEmpty(location.OrganisationName)) result.Add(location.OrganisationName); if (!string.IsNullOrEmpty(location.BuildingName)) { if (location.BuildingName != location.OrganisationName) result.Add(location.BuildingName); } var street = ""; if (!string.IsNullOrEmpty(location.HouseNumber) && location.HouseNumber != "0") { if (location.HouseNumber != location.BuildingName && location.HouseNumber != location.OrganisationName) street += location.HouseNumber; } if (!string.IsNullOrEmpty(location.StreetDescription)) { if (location.StreetDescription != location.BuildingName && location.StreetDescription != location.OrganisationName && location.StreetDescription != location.HouseNumber) street += " " + location.StreetDescription; } if (!string.IsNullOrEmpty(street)) result.Add(street.Trim()); if (!string.IsNullOrEmpty(location.Locality)) { if (location.Locality != location.BuildingName && location.Locality != location.OrganisationName && location.Locality != location.HouseNumber && location.Locality != location.StreetDescription) result.Add(location.Locality); } if (!string.IsNullOrEmpty(location.TownName)) { if (location.TownName != location.BuildingName && location.TownName != location.OrganisationName && location.TownName != location.HouseNumber && location.TownName != location.StreetDescription && location.TownName != location.Locality) result.Add(location.TownName); } if (!string.IsNullOrEmpty(location.AdministrativeArea)) { if (location.AdministrativeArea != location.BuildingName && location.AdministrativeArea != location.OrganisationName && location.AdministrativeArea != location.HouseNumber && location.AdministrativeArea != location.StreetDescription && location.AdministrativeArea != location.Locality && location.AdministrativeArea != location.TownName) result.Add(location.AdministrativeArea); } if (!string.IsNullOrEmpty(location.PostCode)) { if (location.PostCode != location.BuildingName && location.PostCode != location.OrganisationName && location.PostCode != location.HouseNumber && location.PostCode != location.StreetDescription && location.PostCode != location.Locality && location.PostCode != location.TownName && location.PostCode != location.AdministrativeArea) result.Add(location.PostCode); } return result; }
public IEnumerable<Note> GetAvailableNotes(Location location) { return this.catalog.Notes.RetrieveAvailableNotes(location); }
public void UpdateLocation(string sessionKey, Location location) { User dbUser = this.GetUserBySessionKey(sessionKey); var dbLocation = this.locationEntity.Add(location); this.context.SaveChanges(); dbUser.LocationId = dbLocation.Id; this.context.SaveChanges(); }