public override void Draw(CGRect rect) { base.Draw(rect); if (Element.ShadowType == ShadowType.None) { _gradientLayer?.RemoveFromSuperLayer(); return; } if (Element.ShadowType == ShadowType.AcrylicTop) { _gradientLayer?.RemoveFromSuperLayer(); NativeView.Layer.BackgroundColor = new CGColor(1, 1, 1); return; } if (NativeView.Layer.Sublayers != null && NativeView.Layer.Sublayers.Length > 0 && NativeView.Layer.Sublayers[0] is CAGradientLayer) { return; } var gradientsPoints = ComputationHelper.RadiusGradientToPoints(180); // Top shadow var startColor = Color.FromHex("30000000"); var endColor = Color.FromHex("00ffffff"); if (Element.ShadowType == ShadowType.Bottom) { var tmpColor = startColor; startColor = endColor; endColor = tmpColor; } _gradientLayer = new CAGradientLayer { Frame = rect, StartPoint = gradientsPoints.StartPoint.ToPointF(), EndPoint = gradientsPoints.EndPoint.ToPointF(), Colors = new[] { startColor.ToCGColor(), endColor.ToCGColor(), }, }; NativeView.Layer.InsertSublayer(_gradientLayer, 0); _previousSize = Bounds.Size; }
public async Task <IActionResult> Login(UserLoginDTO userLoginDTO) { var userLogin = await _authService.Login(userLoginDTO.Username.ToLower(), userLoginDTO.Password); if (userLogin == null) { return(BadRequest("Incorrect user email or password. Please make sure you input the correct details")); } var userDTO = new UserDTO(); userDTO = _mapper.Map <UserDTO>(userLogin); userDTO.Token = GetAuthenticatedToken(userLogin.Username, userLogin.Id.ToString()); userDTO.Expiry = ComputationHelper.GetTokenValidityInSeconds(1); return(Ok(userDTO)); }
public void IsBatchesAndVoucherTotalCorrect() { var tallyXml = XmlComponentGenerator.TallyXml; Voucher.CreateVoucherXml(tallyXml, "voucherremoteid-123", "20170110", "20170112", "Purchase", "PUR1", "JULIA", "1", "{0}"); //FOR "AL-RG Necklace" AllInventoryEntriesList.CreateAllInventoryEntriesListXml(tallyXml, "Item4desc1", "Item4desc2", "Item4desc3", "AL-RG Necklace", "10.00", "{0}", "IMPORT PURCHASE"); BatchAllocationsList.CreateBatchAllocationsListXml(tallyXml, "AL-RG Necklace", "Kent Box", "-70.00", "7", "7"); BatchAllocationsList.CreateBatchAllocationsListXml(tallyXml, "AL-RG Necklace", "Kent Display", "-50.00", "5", "5"); //FOR "AL-RG Ring" AllInventoryEntriesList.CreateAllInventoryEntriesListXml(tallyXml, "Item5desc1", "Item5desc2", "Item5desc3", "AL-RG Ring", "5.00", "{0}", "IMPORT PURCHASE"); BatchAllocationsList.CreateBatchAllocationsListXml(tallyXml, "AL-RG Ring", "Kent Box", "-100.00", "20", "20"); BatchAllocationsList.CreateBatchAllocationsListXml(tallyXml, "AL-RG Ring", "Kent Display", "-150.00", "30", "30"); string[] expectedBatchesSums = new string[] { "-120.00", "-250.00" }; string[] expectedBatchesQtys = new string[] { "12", "50" }; float expectedVoucherSum = 370.00f; double actualVoucherSum = -AllInventoryEntriesList.CalculateAndFillInventoryEntryAmounts(tallyXml); Assert.AreEqual(expectedVoucherSum, actualVoucherSum); Assert.AreEqual("No", ComputationHelper.IsDeemedPositive((float)actualVoucherSum)); var allInvEntries = tallyXml.XPathSelectElements("//REQUESTDATA//VOUCHER/ALLINVENTORYENTRIES.LIST").ToArray(); Assert.AreEqual(expectedBatchesSums.Length, allInvEntries.Length); for (int i = 0; i < allInvEntries.Length; i++) { string billedQty = allInvEntries[i].Element("BILLEDQTY").Value; string actualQty = allInvEntries[i].Element("ACTUALQTY").Value; Assert.AreEqual(expectedBatchesSums[i], allInvEntries[i].Element("AMOUNT").Value); Assert.AreEqual(expectedBatchesQtys[i], ComputationHelper.ExtractNumericQtyFromString(billedQty)); Assert.AreEqual(expectedBatchesQtys[i], ComputationHelper.ExtractNumericQtyFromString(actualQty)); } }
public async Task <IActionResult> Register(UserRegisterDTO userRegisterDTO) { if (await _authService.isExistUser(userRegisterDTO.Username.ToLower())) { return(BadRequest("User already exists in the database")); } var newUser = new User(); newUser = _mapper.Map <User>(userRegisterDTO); var createdUser = await _authService.Register(newUser, userRegisterDTO.Password); if (createdUser == null) { return(BadRequest("Unable to create user")); } var userDTO = new UserDTO(); userDTO = _mapper.Map <UserDTO>(createdUser); userDTO.Token = GetAuthenticatedToken(createdUser.Username, createdUser.Id.ToString()); userDTO.Expiry = ComputationHelper.GetTokenValidityInSeconds(1); return(Ok(userDTO)); }
public void TestRegex() { Assert.AreEqual("21", ComputationHelper.ExtractNumericQtyFromString(" 21 no")); }