Example #1
0
        public JsonResult Create(Loyalty loyalty)
        {
            try
            {
                if (string.IsNullOrEmpty(loyalty.Name) || string.IsNullOrEmpty(loyalty.Surname))
                {
                    return(Json(new { error = true, errorMessage = "Name and Surname are required" }, JsonRequestBehavior.AllowGet));
                }

                HttpClient httpClient = new HttpClient {
                    BaseAddress = new Uri(_baseUrl)
                };
                httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = httpClient.PostAsJsonAsync("api/Loyalties", loyalty).Result;

                if (response.IsSuccessStatusCode)
                {
                    return(Json(new { error = false }, JsonRequestBehavior.AllowGet));
                }

                return(Json(new { error = true, errorMessage = "Not created" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { error = true, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
        public Task Handle(CreateLoyaltyCommand message)
        {
            var loyalty = new Loyalty(message.Id, message.LoyaltyId, message.EquipmentType, message.Points);

            _session.Add(loyalty);
            return(_session.Commit());
        }
Example #3
0
        public void ProcessMessage(Message message)
        {
            message.Formatter = new XmlMessageFormatter(
                new string[] { "System.String,mscorlib" }
                );
            string json = message.Body.ToString();

            log.Debug("ProcessMessage: Received msg: " + json);
            Cart             cart        = JsonConvert.DeserializeObject <Cart>(json);
            string           invoiceText = "Bondara Equipment Rental Service\n\n";
            RentalCalculator rc          = new RentalCalculator();
            Loyalty          loyalty     = new Loyalty();
            float            total       = 0;
            float            points      = 0;

            foreach (CartItem item in cart.getCartItems())
            {
                invoiceText += "Name: " + item.equipment.name;
                invoiceText += "\t\t\t\t Type: " + item.equipment.type;
                float price = rc.getRentalPrice(item.equipment.type, item.days);
                invoiceText += ", \t\t\t\t Rental Price: " + price + "\n\n\n";
                total       += price;
                points      += loyalty.getPoints(item.equipment.type);
                log.Debug("ProcessMessage: Eq Name:" + item.equipment.name + "|Type:" + item.equipment.type + "|Price:" + price);
            }
            invoiceText += "Total Price: " + total + "\n\n\n";
            invoiceText += "Loyalty Points earned: " + points + "\n";
            log.Debug("ProcessMessage: Total price: " + total + "|Points:" + points);
            FileWriter fw = new FileWriter();

            fw.WriteInvoice("Invoice.txt", invoiceText);
            log.Debug("ProcessMessage: Invoice generated at C:\\Bondora\\Invoices\\Invoice.txt");
        }
        public void CreateGiftCardValue()
        {
            const int valueToAdd = 1000;

            ICreateGiftCardValue  createInterface  = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateGiftCardValue>();
            ILookupUserLoyalty    loyaltyInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ILookupUserLoyalty>();
            IDestroyGiftCardValue destroyInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IDestroyGiftCardValue>();

            Loyalty initialLoyalty = loyaltyInterface.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                                                 LevelUpTestConfiguration.Current.MerchantId);

            var createdGiftCard = createInterface.GiftCardAddValue(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                   LevelUpTestConfiguration.Current.MerchantId,
                                                                   LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                   LevelUpTestConfiguration.Current.ConsumerQrData,
                                                                   valueToAdd);

            Assert.AreEqual(createdGiftCard.AmountAddedInCents, valueToAdd);

            Loyalty postAdditionLoyalty = loyaltyInterface.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                                                      LevelUpTestConfiguration.Current.MerchantId);

            Assert.AreEqual(postAdditionLoyalty.PotentialCreditAmount - initialLoyalty.PotentialCreditAmount, valueToAdd);

            // Cleanup
            destroyInterface.GiftCardDestroyValue(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                  LevelUpTestConfiguration.Current.MerchantId, LevelUpTestConfiguration.Current.ConsumerQrData, valueToAdd);

            Loyalty postDestructionLoyalty = loyaltyInterface.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                                                         LevelUpTestConfiguration.Current.MerchantId);

            Assert.AreEqual(postDestructionLoyalty.PotentialCreditAmount, initialLoyalty.PotentialCreditAmount);
        }
Example #5
0
    public void ChangeLoyalty(Loyalty newloy)
    {
        List <Respect> newRespects = new List <Respect>();

        newRespects.AddRange(newloy.respects);
        newRespects.AddRange(respects);
        float totalNewLoya = 0;
        float total        = 100f;
        float coeff;

        for (int i = 0; i < newRespects.Count; i++)
        {
            totalNewLoya += newRespects[i].val;
        }
        coeff = total / totalNewLoya;
        for (int i = 0; i < newRespects.Count; i++)
        {
            newRespects[i].SetRespect(newRespects[i].val * coeff);
        }

        foreach (var added in newloy.respects)
        {
            Change(added);
        }

        respects.Sort();
    }
Example #6
0
        public async Task <IActionResult> Put(Loyalty loyalty)
        {
            Console.Out.WriteLine(loyalty);
            await this.LoyaltyService.PutLoyalty(loyalty);

            return(RedirectToAction("ListLoyalties"));
        }
Example #7
0
        /// <summary>
        /// Print the object's XML to the XmlWriter.
        /// </summary>
        /// <param name="objWriter">XmlTextWriter to write with.</param>
        /// <param name="objCulture">Culture in which to print.</param>
        /// <param name="strLanguageToPrint">Language in which to print</param>
        public void Print(XmlTextWriter objWriter, CultureInfo objCulture, string strLanguageToPrint)
        {
            objWriter.WriteStartElement("contact");
            objWriter.WriteElementString("name", Name);
            objWriter.WriteElementString("role", DisplayRoleMethod(strLanguageToPrint));
            objWriter.WriteElementString("location", Location);
            if (!IsGroup)
            {
                objWriter.WriteElementString("connection", Connection.ToString(objCulture));
            }
            else
            {
                objWriter.WriteElementString("connection", LanguageManager.GetString("String_Group", strLanguageToPrint) + "(" + Connection.ToString(objCulture) + ')');
            }
            objWriter.WriteElementString("loyalty", Loyalty.ToString(objCulture));
            objWriter.WriteElementString("metatype", DisplayMetatypeMethod(strLanguageToPrint));
            objWriter.WriteElementString("sex", DisplaySexMethod(strLanguageToPrint));
            objWriter.WriteElementString("age", DisplayAgeMethod(strLanguageToPrint));
            objWriter.WriteElementString("contacttype", DisplayTypeMethod(strLanguageToPrint));
            objWriter.WriteElementString("preferredpayment", DisplayPreferredPaymentMethod(strLanguageToPrint));
            objWriter.WriteElementString("hobbiesvice", DisplayHobbiesViceMethod(strLanguageToPrint));
            objWriter.WriteElementString("personallife", DisplayPersonalLifeMethod(strLanguageToPrint));
            objWriter.WriteElementString("type", LanguageManager.GetString("String_" + EntityType.ToString(), strLanguageToPrint));
            objWriter.WriteElementString("forcedloyalty", ForcedLoyalty.ToString(objCulture));
            objWriter.WriteElementString("blackmail", Blackmail.ToString());
            objWriter.WriteElementString("family", Family.ToString());
            if (CharacterObject.Options.PrintNotes)
            {
                objWriter.WriteElementString("notes", Notes);
            }

            PrintMugshots(objWriter);

            objWriter.WriteEndElement();
        }
        public Loyalty NewLoyalty(Loyalty data)
        {
            _rightsManager.CheckRole(AccountRole.Admin);

            var loyalAcc = UserContext.Accounts.GetOrFail(data.LoyalName);//_userManager.FindById(data.LoyalName);

            Try.Condition(loyalAcc.Role.IsCompany(), $"{loyalAcc.Login} не является компанией");

            var check = UserContext.Data.Loyalties.Where(x =>
                                                         x.LoyalName == loyalAcc.Login && x.Insurance == data.Insurance);

            Try.Condition(!check.Any(), $"Компания уже обслуживает данную страховку");
            Try.Condition(data.MinLevel < 4 && data.MinLevel > 0, $"Значения MinLevel разрешены в диапазоне [1:3]");

            var loyalty = new Loyalty(loyalAcc, data.Insurance);

            loyalty.MinLevel = data.MinLevel;

            UserContext.Data.Loyalties.Add(loyalty);
            UserContext.Data.SaveChanges();

            var issuerAcc = GetIssuerFromType(data.Insurance);

            UserContext.AddGameEvent(issuerAcc.Login, GameEventType.Insurance,
                                     $"Вашу страховку теперь обслуживает {loyalAcc.DisplayName}", true);

            UserContext.AddGameEvent(loyalAcc.Login, GameEventType.Insurance,
                                     $"Вы начали обслуживать страховку {loyalty.Insurance}", true);

            return(loyalty);
        }
Example #9
0
 public Team Merger(Loyalty newLoyalty)
 {
     for (int i = 0; i < newLoyalty.respects.Count; i++)
     {
         ChangeLoyalty(newLoyalty.respects[i]);
     }
     return(respects[0].team);
 }
        public virtual void ProcessRequest(HttpContext context)
        {
            try {
                HttpRequest request = context.Request;

                // get credentials and settings
                WobCredentials credentials = new WobCredentials(
                    WebConfigurationManager.AppSettings["ServiceAccountId"],
                    WebConfigurationManager.AppSettings["ServiceAccountPrivateKey"],
                    WebConfigurationManager.AppSettings["ApplicationName"],
                    WebConfigurationManager.AppSettings["IssuerId"]);

                string loyaltyClassId   = WebConfigurationManager.AppSettings["LoyaltyClassId"];
                string loyaltyObjectId  = WebConfigurationManager.AppSettings["LoyaltyObjectId"];
                string offerClassId     = WebConfigurationManager.AppSettings["OfferClassId"];
                string offerObjectId    = WebConfigurationManager.AppSettings["OfferObjectId"];
                string giftCardClassId  = WebConfigurationManager.AppSettings["GiftCardClassId"];
                string giftCardObjectId = WebConfigurationManager.AppSettings["GiftCardObjectId"];

                // OAuth - setup certificate based on private key file
                X509Certificate2 certificate = new X509Certificate2(
                    AppDomain.CurrentDomain.BaseDirectory + credentials.serviceAccountPrivateKey,
                    "notasecret",
                    X509KeyStorageFlags.Exportable);

                WobUtils utils = new WobUtils(credentials.serviceAccountId, certificate);

                // get the object type
                string type = request.Params["type"];

                if (type.Equals("loyalty"))
                {
                    LoyaltyObject loyaltyObject = Loyalty.generateLoyaltyObject(credentials.IssuerId, loyaltyClassId, loyaltyObjectId);
                    utils.addObject(loyaltyObject);
                }
                else if (type.Equals("offer"))
                {
                    OfferObject offerObject = Offer.generateOfferObject(credentials.IssuerId, offerClassId, offerObjectId);
                    utils.addObject(offerObject);
                }
                else if (type.Equals("giftcard"))
                {
                    GiftCardObject giftCardObject = GiftCard.generateGiftCardObject(credentials.IssuerId, giftCardClassId, giftCardObjectId);
                    utils.addObject(giftCardObject);
                }

                // generate the JWT
                string jwt = utils.GenerateJwt();

                HttpResponse response = context.Response;
                response.Write(jwt);
                //response.ContentType = "text/xml";
            }
            catch (Exception e) {
                Console.Write(e.StackTrace);
            }
        }
        public virtual void ProcessRequest(HttpContext context)
        {
            try
            {
                HttpRequest request = context.Request;

                // get settings
                WobCredentials credentials = new WobCredentials(
                    WebConfigurationManager.AppSettings["ServiceAccountId"],
                    WebConfigurationManager.AppSettings["ServiceAccountPrivateKey"],
                    WebConfigurationManager.AppSettings["ApplicationName"],
                    WebConfigurationManager.AppSettings["IssuerId"]);

                string loyaltyClassId = WebConfigurationManager.AppSettings["LoyaltyClassId"];
                string offerClassId   = WebConfigurationManager.AppSettings["OfferClassId"];

                // OAuth - setup certificate based on private key file
                X509Certificate2 certificate = new X509Certificate2(
                    AppDomain.CurrentDomain.BaseDirectory + credentials.serviceAccountPrivateKey,
                    "notasecret",
                    X509KeyStorageFlags.Exportable);

                // create service account credential
                ServiceAccountCredential credential = new ServiceAccountCredential(
                    new ServiceAccountCredential.Initializer(credentials.serviceAccountId)
                {
                    Scopes = new[] { "https://www.googleapis.com/auth/wallet_object.issuer" }
                }.FromCertificate(certificate));

                // create the service
                var woService = new WalletobjectsService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = credential,
                    ApplicationName       = "Wallet Objects API Sample",
                });

                // get the class type
                string type = request.Params["type"];

                // insert the class
                if (type.Equals("loyalty"))
                {
                    LoyaltyClass loyaltyClass = Loyalty.generateLoyaltyClass(credentials.IssuerId, loyaltyClassId);
                    woService.Loyaltyclass.Insert(loyaltyClass).Execute();
                }
                else if (type.Equals("offer"))
                {
                    OfferClass offerClass = Offer.generateOfferClass(credentials.IssuerId, offerClassId);
                    woService.Offerclass.Insert(offerClass).Execute();
                }
            }
            catch (Exception e)
            {
                Console.Write(e.StackTrace);
            }
        }
Example #12
0
        /// <summary>
        /// Handles the DrawItem event of the lbLoyalty control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.DrawItemEventArgs"/> instance containing the event data.</param>
        private void lbLoyalty_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0 || e.Index >= lbLoyalty.Items.Count)
            {
                return;
            }

            Loyalty loyalty = lbLoyalty.Items[e.Index] as Loyalty;

            DrawItem(loyalty, e);
        }
        // Post: Loyalties/RemovePatient?Loyalty
        public async Task <ActionResult> RemovePatient(int id)
        {
            Loyalty dto = await db.Loyalties.FindAsync(id);

            UpdatePatientRemove(dto.PatientId);
            db.Loyalties.Remove(dto);
            await db.SaveChangesAsync();

            TempData["SM"] = "You have removed a patient from loyalty list";
            return(RedirectToAction("Index"));
        }
        private void LoadLoyaltyPointAsync( )
        {
            var credential = DependencyService.Get <ICredentialRetriever>().GetCredential();
            var loyalty    = Global.GetLoyalty();// await Helpers.APIHelper.GetLoyaltyAsync();

            if (loyalty == null)
            {
                loyalty = new Loyalty();
            }
            // ViewModels. LeadUpdate(loyalty);
            //  System.Diagnostics.Debug.WriteLine("loyalty " + loyalty.Name);
        }
Example #15
0
        public async Task <Loyalty> PatchLoyalty(Loyalty loyalty)
        {
            var sendContent = new StringContent(JsonSerializer.Serialize(loyalty), Encoding.UTF8, "application/json");

            using var response = await this.HttpClient.PatchAsync("api/loyalty", sendContent);

            response.EnsureSuccessStatusCode();
            var content = await response.Content.ReadAsStringAsync();

            return(JsonSerializer.Deserialize <Loyalty>(content, new JsonSerializerOptions {
                PropertyNameCaseInsensitive = true
            }));
        }
Example #16
0
        public ActionResult Loyalty()
        {
            var botChannelSettings = ContextService.GetBotChannelSettings(ContextService.GetUser(User.Identity.Name));

            if (botChannelSettings.Loyalty != null)
            {
                return(Json(JsonConvert.SerializeObject(botChannelSettings.Loyalty)));
            }
            else
            {
                var loyalty = new Loyalty();
                return(Json(JsonConvert.SerializeObject(loyalty)));
            }
        }
Example #17
0
        /// <summary>
        /// Draws the list item for the given loyalty point balance
        /// </summary>
        /// <param name="loyalty"></param>
        /// <param name="e"></param>
        private void DrawItem(Loyalty loyalty, DrawItemEventArgs e)
        {
            Graphics g = e.Graphics;

            // Draw background
            g.FillRectangle(e.Index % 2 == 0 ? Brushes.White : Brushes.LightGray, e.Bounds);

            // Texts - corp on first row, points on last row
            string corp        = loyalty.CorporationName;
            string loyaltyText = $"{loyalty.LoyaltyPoints}";
            string pointText   = loyalty.LoyaltyPoints == 1 ? "point" : "points";

            // Measure texts
            Size corpTextSize    = TextRenderer.MeasureText(g, corp, m_loyaltyBoldFont, Size.Empty, Format);
            Size loyaltyTextSize = TextRenderer.MeasureText(g, loyaltyText, m_loyaltyBoldFont, Size.Empty, Format);
            Size pointTextSize   = TextRenderer.MeasureText(g, pointText, m_loyaltyFont, Size.Empty, Format);

            // Draw texts
            TextRenderer.DrawText(g, corp, m_loyaltyBoldFont,
                                  new Rectangle(
                                      e.Bounds.Left + PadLeft * 7,
                                      e.Bounds.Top + PadTop,
                                      corpTextSize.Width + PadLeft,
                                      corpTextSize.Height), Color.Black);

            TextRenderer.DrawText(g, loyaltyText, m_loyaltyBoldFont,
                                  new Rectangle(
                                      e.Bounds.Left + PadLeft * 7,
                                      e.Bounds.Top + PadTop + corpTextSize.Height,
                                      loyaltyTextSize.Width + PadLeft,
                                      loyaltyTextSize.Height), Color.Black);

            TextRenderer.DrawText(g, pointText, m_loyaltyFont,
                                  new Rectangle(
                                      e.Bounds.Left + PadLeft * (7 + 1) + loyaltyTextSize.Width,
                                      e.Bounds.Top + PadTop + corpTextSize.Height,
                                      pointTextSize.Width + PadLeft,
                                      pointTextSize.Height), Color.Black);

            // Draw the corporation image
            if (Settings.UI.SafeForWork)
            {
                return;
            }

            g.DrawImage(loyalty.CorporationImage,
                        new Rectangle(e.Bounds.Left + PadLeft / 2,
                                      LoyaltyDetailHeight / 2 - loyalty.CorporationImage.Height / 2 + e.Bounds.Top,
                                      loyalty.CorporationImage.Width, loyalty.CorporationImage.Height));
        }
Example #18
0
        private void WireServiceInstances()
        {
            Document = new Document {
                Uploads = GetService <UploadsService>()
            };

            General = new General
            {
                News                = GetService <NewsService>(),
                Accountdevices      = GetService <AccountDevicesService>(),
                Accounts            = GetService <AccountsService>(),
                Merchants           = GetService <MerchantsService>(),
                Publicmerchants     = GetService <PublicMerchantsService>(),
                Stores              = GetService <StoresService>(),
                GeneralTransactions = GetService <GeneralTransactionsService>()
            };

            Payment = new Payment
            {
                Containers         = GetService <ContainersService>(),
                Customers          = GetService <CustomerPaymentService>(),
                Secupaycreditcards = GetService <SecupayCreditcardsService>(),
                Secupaydebits      = GetService <SecupayDebitsService>(),
                Secupayprepays     = GetService <SecupayPrepaysService>(),
                Contracts          = GetService <ContractService>(),
                Secupayinvoices    = GetService <SecupayInvoicesService>()
            };

            Loyalty = new Loyalty
            {
                Cards           = GetService <CardsService>(),
                CustomerLoyalty = GetService <CustomerLoyaltyService>(),
                Merchantcards   = GetService <MerchantCardsService>(),
            };


            Services = new Services
            {
                Identrequests = GetService <IdentRequestsService>(),
                Identresults  = GetService <IdentResultsService>()
            };

            Smart = new Smart
            {
                Checkins     = GetService <CheckinsService>(),
                Idents       = GetService <IdentsService>(),
                Transactions = GetService <SmartTransactionsService>()
            };
        }
Example #19
0
        public async Task CreateAsync_loyaltyValidationSucceed_Createsloyalty()
        {
            // Arrange
            var loyalty  = new LoyaltyUpdateModel();
            var expected = new Loyalty();

            var loyaltyDAL = new Mock <ILoyaltyDAL>();

            loyaltyDAL.Setup(x => x.InsertAsync(loyalty)).ReturnsAsync(expected);

            var loyaltyService = new LoyaltyService(loyaltyDAL.Object);

            // Act
            var result = await loyaltyService.CreateAsync(loyalty);

            // Assert
            result.Should().Be(expected);
        }
Example #20
0
        public async Task ValidateAsync_loyaltyExists_DoesNothing()
        {
            // Arrange
            var loyaltyContainer = new Mock <ILoyaltyContainer>();

            var loyalty         = new Loyalty();
            var loyaltyDAL      = new Mock <ILoyaltyDAL>();
            var loyaltyIdentity = new Mock <ILoyaltyIdentity>();

            loyaltyDAL.Setup(x => x.GetAsync(loyaltyIdentity.Object)).ReturnsAsync(loyalty);

            var loyaltyGetService = new LoyaltyService(loyaltyDAL.Object);

            // Act
            var action = new Func <Task>(() => loyaltyGetService.ValidateAsync(loyaltyContainer.Object));

            // Assert
            await action.Should().NotThrowAsync <Exception>();
        }
Example #21
0
        public Loyalty GetLoyalty()
        {
            var credential = DependencyService.Get <ICredentialRetriever>().GetCredential();

            //  var ls = new Lead();

            System.Diagnostics.Debug.WriteLine($"{UmbrellaApi.SCHEME}://{UmbrellaApi.API_HOST_URL}/loyaltycard/");

            // var client = new RestSharp.RestClient("http://mastereman.com/restful/sampleleads.php");

            var ls      = new Loyalty();
            var client  = new RestSharp.RestClient($"{UmbrellaApi.SCHEME}://{UmbrellaApi.API_HOST_URL}/loyaltycard/");
            var request = new RestRequest(Method.POST);

            request.AddParameter("partner_id", credential.UserID.ToString());
            request.AddHeader("umbrella-api-username", UmbrellaApi.USERNAME);
            request.AddHeader("umbrella-api-key", UmbrellaApi.PASSKEY);
            request.AddHeader("umbrella-partner-id", UmbrellaApi.PARTNER_ID);
            //   var content = response.Content;
            // List<Lead> convert = null;
            EventWaitHandle Wait = new AutoResetEvent(false);

            var asyncHandle = client.ExecuteAsync <Loyalty>(request, response => {
                System.Diagnostics.Debug.WriteLine("Loyalty " + response.Content);
                try
                {
                    var json = response.Content.Replace("<", "");
                    ls       = JsonConvert.DeserializeObject <Loyalty>(json);
                    App.LoyaltyDatabase.SaveLoyaltysAsync(ls);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("ERRor : " + e.ToString());
                    ls = new Loyalty();
                }

                Wait.Set();
            });

            Wait.WaitOne();

            return(ls);
        }
        public string Approved()
        {
            var sessionId     = Session["id"];
            var appointmentId = Session["AppointmentId"];
            var OrderId       = Session["orderId"];
            int appId         = Convert.ToInt32(appointmentId);
            int ordId         = Convert.ToInt32(OrderId);
            int patientId     = Convert.ToInt32(sessionId);

            Appointment appointment = db.Appointments.Where(a => a.AppointmentID.Equals(appId))
                                      .FirstOrDefault();
            Loyalty loyalty = db.Loyalties.Where(l => l.PatientId.Equals(patientId))
                              .FirstOrDefault();
            Order order = db.Orders.Where(l => l.OrderID.Equals(ordId))
                          .FirstOrDefault();

            if (loyalty == null)
            {
                loyalty = new Loyalty();
            }
            else
            {
                if (loyalty.Loyalty_Points >= 100)
                {
                    loyalty.Loyalty_Points = 0;
                }
                else
                {
                    loyalty.Loyalty_Points += 10;
                }
                db.Entry(loyalty).State = EntityState.Modified;
            }

            appointment.isPaid = true;
            order.isApproved   = true;

            db.Entry(appointment).State = EntityState.Modified;
            db.SaveChanges();

            return("Approved");
        }
Example #23
0
        private void LoadLoyaltyPointAsync()
        {
            var credential = DependencyService.Get <ICredentialRetriever>().GetCredential();
            var loyalty    = Global.GetLoyalty();

            if (loyalty == null)
            {
                loyalty = new Loyalty();
            }
            lblLoyaltyPoints.Text = loyalty.Points;
            lblPartnerID.Text     = loyalty.PartnerId;
            lblPackage.Text       = loyalty.PackageLevel;
            fullnameText.Text     = loyalty.Fullname;
            if (loyalty.Barcode == "")
            {
                loyalty.Barcode = "0 77456 049283";
            }
            //imgbarcode.Source = string.IsNullOrEmpty(loyalty.barcode_url) ? "barcode_image.png" : loyalty.barcode_url;
            imgbarcode.Source = loyalty.BarcodeUrl;
            lblbarcode.Text   = loyalty.Barcode;
        }
Example #24
0
        public async Task ValidateAsync_loyaltyNotExists_ThrowsError()
        {
            // Arrange
            var fixture = new Fixture();
            var id      = fixture.Create <int>();

            var loyaltyContainer = new Mock <ILoyaltyContainer>();

            loyaltyContainer.Setup(x => x.LoyaltyId).Returns(id);
            var loyaltyIdentity = new Mock <ILoyaltyIdentity>();
            var loyalty         = new Loyalty();
            var loyaltyDAL      = new Mock <ILoyaltyDAL>();

            loyaltyDAL.Setup(x => x.GetAsync(loyaltyIdentity.Object)).ReturnsAsync((Loyalty)null);

            var loyaltyGetService = new LoyaltyService(loyaltyDAL.Object);

            // Act
            var action = new Func <Task>(() => loyaltyGetService.ValidateAsync(loyaltyContainer.Object));
            // Assert
            await action.Should().ThrowAsync <InvalidOperationException>($"Loyalty not found by id {id}");
        }
Example #25
0
 /// <summary>Construct Public ESI interface</summary>
 public Public() : base()
 {
     Alliance             = new AllianceMain(this);
     Character            = new CharacterMain(this);
     Corporation          = new CorporationMain(this);
     Dogma                = new Dogma(this);
     FactionWarfare       = new FactionWarfare(this);
     Incursions           = new Incursions(this);
     Industry             = new Industry(this);
     Insurance            = new Insurance(this);
     Killmails            = new Killmails(this);
     Loyalty              = new Loyalty(this);
     Market               = new Market(this);
     Opportunities        = new Opportunities(this);
     PlanetaryInteraction = new PlanetaryInteraction(this);
     Routes               = new Routes(this);
     Search               = new Search(this);
     Sovereignty          = new Sovereignty(this);
     Status               = new Status(this);
     Universe             = new Universe(this);
     Wars = new Wars(this);
 }
Example #26
0
        /// <summary>
        /// SetLoyalty for channel
        /// </summary>
        /// <param name="user">ApplicationUser</param>
        /// <param name="loyalty">loyalty</param>
        /// <returns>Loyalty</returns>
        public Loyalty SetLoyalty(ApplicationUser user, Loyalty loyalty)
        {
            Context = new ApplicationDbContext();

            var channelSettings = GetBotChannelSettings(user);

            if (channelSettings.Loyalty == null)
            {
                channelSettings.Loyalty = loyalty;
            }
            else
            {
                channelSettings.Loyalty.LoyaltyName     = loyalty.LoyaltyName;
                channelSettings.Loyalty.LoyaltyValue    = loyalty.LoyaltyValue;
                channelSettings.Loyalty.LoyaltyInterval = loyalty.LoyaltyInterval;
                channelSettings.Loyalty.Track           = loyalty.Track;
            }

            Context.SaveChanges();

            return(channelSettings.Loyalty);
        }
Example #27
0
        public void setData()
        {
            APIHelper2 a      = new APIHelper2();
            var        reward = a.GetReward();
            // var topCom = a.GetTopComrades();
            var topRec = a.GetTopRecruits();

            //var topResou = a.GetTopResources();
            // Global.SetTopCom(topCom);
            Global.SetTopRec(topRec);
            //Global.SetTopReso(topResou);
            Global.SetrewardPoints(reward.Number);
            Global.SetRankTitle(reward.Title);
            var     res     = a.GetLead();
            Loyalty loyalty = a.GetLoyalty();

            Global.SetLoyalty(loyalty);
            var medals = a.GetMedals();

            Global.SetMedalList(medals);
            App.LeadsDatabase.SaveLeadsAsync(res);
            this.SetProperty(ref this._leads, res);
        }
Example #28
0
        public ActionResult LoyaltySave(string loyaltyName, string loyaltyValue, string loyaltyInterval, string track)
        {
            try
            {
                var userName = User.Identity.Name;
                var user     = ContextService.GetUser(userName);

                var loyalty = new Loyalty();
                if (track == null)
                {
                    loyalty.Track = false;
                }
                else
                {
                    if (Convert.ToInt32(track) == 1)
                    {
                        loyalty.Track = true;
                    }
                    else
                    {
                        loyalty.Track = false;
                    }
                }
                loyalty.LoyaltyName     = loyaltyName;
                loyalty.LoyaltyInterval = Convert.ToInt32(loyaltyInterval);
                loyalty.LoyaltyValue    = Convert.ToInt32(loyaltyValue);

                ContextService.SetLoyalty(user, loyalty);

                return(Json(new { data = "1", message = "Saved loyalty" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception exception)
            {
                return(Json(new { data = "-1", message = "Error on save: " + exception.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Example #29
0
 public Task <int> SaveLoyaltysAsync(Loyalty item)
 {
     database.DropTableAsync <Loyalty>().Wait();
     database.CreateTableAsync <Loyalty>().Wait();
     return(database.InsertAsync(item));
 }
Example #30
0
 public static void SetLoyalty(Loyalty Loyalty)
 {
     loyalty = Loyalty;
 }