/// <summary> /// This method converts Polar Coordinates into Cartesian Coordinates /// See the following for explanation: https://en.wikipedia.org/wiki/Polar_coordinate_system#Converting_between_polar_and_Cartesian_coordinates /// Tip: User angle is provided in Degrees, but needs to be converted to Radians for math to work /// </summary> /// <param name="request"></param> /// <returns></returns> public static Response <CartesianCoordinates> PolarToCartesian(PolarCoordinates request) { var response = new Response <CartesianCoordinates>(); var cMethodName = "GeometryService.PolarToCartesian(..)"; try { if (request == null) { throw new ArgumentException(DomainResource.NullRequest); } if (request.DistanceFromOrigin == null) { throw new ArgumentException(string.Format(DomainResource.XCannotBeNullOrEmpty, "Distance From Origin")); } if (request.Angle == null) { throw new ArgumentException(string.Format(DomainResource.XCannotBeNullOrEmpty, "Angle")); } if (request.DistanceFromOrigin < 0) { throw new ArgumentException(string.Format(DomainResource.XCannotBeNegative, "Distance From Origin")); } response.Value = new CartesianCoordinates(); response.Value.XLocation = 0; response.Value.YLocation = 0; var radians = request.Angle.Value * (Math.PI / 180); response.Value.XLocation = request.DistanceFromOrigin * Math.Cos(radians); response.Value.YLocation = request.DistanceFromOrigin * Math.Sin(radians); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; var logData = new { Request = request, Exception = ex }; var msg = string.Format(DomainResource.ErrorOccuredInXY, cMethodName, ex.Message); LoggerService.Log(LogArea.Math, GeneralHelper.ExceptionLogType(ex), msg, logData); } return(response); }
/// <summary> /// This method should return all Product records which match the search criteria provided /// - TextFilter (optional) /// Filters products based on Code or Description containing the text /// </summary> /// <param name="request"></param> /// <returns></returns> public Response <List <Product> > GetProducts(ProductRequest request) { var response = new Response <List <Product> >(); var cMethodName = "OrderService.GetProducts(..)"; try { if (request == null) { throw new ArgumentException(DomainResource.NullRequest); } var sqlQuery = @"<Your SQL Code Here>"; var sqlResponse = Database.Read <Product>(sqlQuery); if (sqlResponse.Success) { response.Value = sqlResponse.Value; } } catch (Exception ex) { response.Success = false; response.Message = ex.Message; var logData = new { Request = request, Exception = ex }; var msg = string.Format(DomainResource.ErrorOccuredInXY, cMethodName, ex.Message); LoggerService.Log(LogArea.Sales, GeneralHelper.ExceptionLogType(ex), msg, logData); } return(response); }