/// <summary>
        /// Get the Azure CSP Rate Card Meter List from the Rate Card JSON specified as input
        /// </summary>
        /// <param name="rateCard">The string containing the JSON for Azure CSP Rate Card</param>
        /// <param name="currency">CSP Currency</param>
        /// <returns> Returns the Azure CSP Rate Card Meter List</returns>
        public static List <Meter> GetRateCard(string rateCard, out string currency)
        {
            List <Meter> rateCardMetersList = null;

            currency = string.Empty;

            // Load from string
            try
            {
                RateCard card = JsonConvert.DeserializeObject <RateCard>(rateCard);

                if (card != null && card.Meters != null && card.Meters.Count() > 0)
                {
                    rateCardMetersList = card.Meters;
                    currency           = card.Currency;
                }
                else
                {
                    throw new Exception(APICallErrorLiterals.RateCardNullOrZeroRecordsError);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(rateCardMetersList);
        }
Exemplo n.º 2
0
        private double GetRateFrom(RateCard aRateCard, int aRows)
        {
            int start1 = Int32.Parse(aRateCard.BandStart1);
            int end1   = Int32.Parse(aRateCard.BandEnd1);

            int start2 = Int32.Parse(aRateCard.BandStart2);
            int end2   = Int32.Parse(aRateCard.BandEnd2);

            int start3 = Int32.Parse(aRateCard.BandStart3);
            int end3   = Int32.Parse(aRateCard.BandEnd3);

            int start4 = Int32.Parse(aRateCard.BandEnd4);
            int end4   = Int32.Parse(aRateCard.BandEnd4);

            if (aRows >= start1 && aRows <= end1)
            {
                return(Double.Parse(aRateCard.Rate1));
            }
            else if (aRows >= start2 && aRows <= end2)
            {
                return(Double.Parse(aRateCard.Rate2));
            }
            else if (aRows >= start3 && aRows <= end4)
            {
                return(Double.Parse(aRateCard.Rate3));
            }
            else
            {
                return(Double.Parse(aRateCard.Rate4));
            }
        }
Exemplo n.º 3
0
        public bool addRateCard(RateCard rateCard)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();
                con.Open();
                cmd.Connection  = con;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "spAddRateCard";
                cmd.Parameters.AddWithValue("@rateCardName", rateCard.RateCardName);
                cmd.Parameters.AddWithValue("@VehicleCategoryId", rateCard.VehicleCategoryId);
                cmd.Parameters.AddWithValue("@VehicleMakerId", rateCard.VehicleMakerID);
                cmd.Parameters.AddWithValue("@VehicleModelId", rateCard.VehicleModelId);
                cmd.Parameters.AddWithValue("@VehicleBaseRate", rateCard.BaseRate);
                cmd.Parameters.AddWithValue("@VehicleDailyRate", rateCard.DailyRate);
                cmd.Parameters.AddWithValue("@VehicleWeeklyRate", rateCard.WeeklyRate);
                cmd.Parameters.AddWithValue("@VehicleMonthlyRate", rateCard.MonthlyRate);
                cmd.Parameters.AddWithValue("@StartDate", rateCard.StartDate);
                cmd.Parameters.AddWithValue("@EndDate", rateCard.EndDate);
                cmd.Parameters.AddWithValue("@IsActive", rateCard.IsActive);
                cmd.Parameters.AddWithValue("@Starttime", rateCard.starttime);
                cmd.Parameters.AddWithValue("@Endtime", rateCard.endtime);

                cmd.ExecuteNonQuery();
                con.Close();
                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(false);
            }
        }
Exemplo n.º 4
0
        public JsonResult PostRateCard([FromBody] RateCard aData)
        {
            bool updated = false;

            if (aData.Fn != null)
            {
                if (aData.Fn.Equals("Add"))
                {
                    updated = bl.AddRateCard(aData);
                }
                else if (aData.Fn.Equals("Delete"))
                {
                    updated = bl.DeleteRateCard(aData);
                }
                else
                {
                    updated = bl.UpdateRateCard(aData);
                }
                if (updated == true)
                {
                    return(new JsonResult(new List <RateCard> {
                        aData
                    }));
                }
                else
                {
                    return(new JsonResult(null));
                }
            }
            else
            {
                return(new JsonResult(null));
            }
        }
Exemplo n.º 5
0
        private List <RateCard> GetListOfRateCard(bool aForce)
        {
            try {
                Query query = new Query("RateCard")
                {
                    Order = { { "Type", PropertyOrder.Types.Direction.Ascending } }
                };

                IReadOnlyList <Entity> results = this.adapter.Query(query);
                List <RateCard>        rcs     = new List <RateCard>();
                foreach (Entity entity in results)
                {
                    string type   = (string)entity["Type"];
                    int    start1 = (int)entity["Band1_Start"];
                    int    end1   = (int)entity["Band1_End"];
                    Double rate1  = (double)entity["Rate1"];
                    int    start2 = (int)entity["Band2_Start"];
                    int    end2   = (int)entity["Band2_End"];
                    Double rate2  = (double)entity["Rate2"];
                    int    start3 = (int)entity["Band3_Start"];
                    int    end3   = (int)entity["Band3_End"];
                    Double rate3  = (double)entity["Rate3"];
                    int    start4 = (int)entity["Band4_Start"];
                    int    end4   = (int)entity["Band4_End"] == 0 ? Int32.MaxValue : (int)entity["Band4_End"];
                    Double rate4  = (double)entity["Rate4"];

                    List <Path> paths = JsonConvert.DeserializeObject <List <Path> >(entity.Key.Path.ToString());
                    string      id    = paths[0].Id;

                    RateCard rc = new RateCard();
                    rc.Type       = type;
                    rc.BandStart1 = start1.ToString();
                    rc.BandEnd1   = end1.ToString();
                    rc.Rate1      = rate1.ToString();
                    rc.BandStart2 = start2.ToString();
                    rc.BandEnd2   = end2.ToString();
                    rc.Rate2      = rate2.ToString();
                    rc.BandStart3 = start3.ToString();
                    rc.BandEnd3   = end3.ToString();
                    rc.Rate3      = rate3.ToString();
                    rc.BandStart4 = start4.ToString();
                    rc.BandEnd4   = end4.ToString();
                    rc.Rate4      = rate4.ToString();
                    rc.Id         = id;

                    rcs.Add(rc);
                }
                return(rcs);
            }
            catch (Exception aEx) {
                Console.Out.Write(aEx.Message);
                return(null);
            }
        }
Exemplo n.º 6
0
        private void btnaddratecard_Click(object sender, EventArgs e)
        {
            if (comboBoxMaker.SelectedValue == null || comboBoxModel.SelectedValue == null || txtboxbaserate.Text.ToString() == "" ||
                txtBoxDailyRate.Text.ToString() == "" || txtBoxWeeklyRate.Text.ToString() == "" || txtBoxMonthlyRate.Text.ToString() == "" ||
                txtboxratecardname.Text.ToString() == ""
                )
            {
                RadMessageBox.Show("Enter All The Fields");
                return;
            }
            bool active = false;

            if (radiobtnactive.Checked)
            {
                active = true;
            }
            if (dtendtime.Value.TimeOfDay < dtstarttime.Value.TimeOfDay)
            {
                RadMessageBox.Show("End Time Cannot be Before the Start time");
                dtendtime.Value = DateTime.Now;
                return;
            }
            RateCard ratecard = new RateCard()
            {
                RateCardName      = txtboxratecardname.Text.ToString(),
                VehicleCategoryId = Convert.ToInt32(comboBoxCategory.SelectedValue.ToString()),
                VehicleMakerID    = Convert.ToInt32(comboBoxMaker.SelectedValue.ToString()),
                VehicleModelId    = Convert.ToInt32(comboBoxModel.SelectedValue.ToString()),
                BaseRate          = Convert.ToDecimal(txtboxbaserate.Text.ToString()),
                DailyRate         = Convert.ToDecimal(txtBoxDailyRate.Text.ToString()),
                WeeklyRate        = Convert.ToDecimal(txtBoxWeeklyRate.Text.ToString()),
                MonthlyRate       = Convert.ToDecimal(txtBoxMonthlyRate.Text.ToString()),
                StartDate         = dtstrtdate.Value,
                EndDate           = dtenddate.Value,
                IsActive          = active,
                starttime         = dtstarttime.Value.ToShortTimeString().ToString(),
                endtime           = dtendtime.Value.ToShortTimeString().ToString()
            };

            if (new RateCardBusiness().addRateCard(ratecard))
            {
                RadMessageBox.Show("Succesfully Added");
                lblstrt.Visible     = false;
                lblend.Visible      = false;
                dtstarttime.Visible = false;
                dtendtime.Visible   = false;
                //
                dgvinitialize();
            }
            else
            {
                RadMessageBox.Show("Failed");
            }
        }
Exemplo n.º 7
0
        public ResellerService()
        {
            tenant_name      = System.Configuration.ConfigurationManager.AppSettings["reseller_tenant_name"];
            crest_account_id = System.Configuration.ConfigurationManager.AppSettings["crest_account_id"];
            crest_app_id     = System.Configuration.ConfigurationManager.AppSettings["crest_app_id"];
            crest_app_key    = System.Configuration.ConfigurationManager.AppSettings["crest_app_key"];
            graph_app_id     = System.Configuration.ConfigurationManager.AppSettings["graph_app_id"];
            graph_app_key    = System.Configuration.ConfigurationManager.AppSettings["graph_app_key"];

            rateCard = new RateCard();
        }
Exemplo n.º 8
0
 public static Videa.InventoryGuideNS.Data.DataServices.RateCard ToEntity(this RateCard source)
 {
     return(new Videa.InventoryGuideNS.Data.DataServices.RateCard
     {
         RateCardHashKey = source.RateCardHashKey.ToCharArray(),
         RateCardSqn = source.RateCardSqn,
         RateCardName = source.RateCardName,
         RateCardStartDate = source.RateCardStartDate.ToDateTime(),
         RateCardEndDate = source.RateCardEndDate.ToDateTime()
     });
 }
Exemplo n.º 9
0
        /// <summary>
        /// Gets the Meters for the Azure CSP Rate Card
        /// </summary>
        /// <param name="cspCreds">CSP Account credentials object. A token will be generated using these credentials and used for making the online Partner Center API call</param>
        /// <returns> Returns the list of Azure Meters</returns>
        public static List <Meter> GetRateCard(CSPAccountCreds cspCreds)
        {
            List <Meter> meterList = null;

            try
            {
                if (cspCreds == null)
                {
                    throw new Exception(ExceptionLogger.GenerateLoggerTextForInternalError("CSP Account Credentials is null"));
                }

                // Fetch the AzureAD Token
                string aadToken = AuthManager.GetAzureADTokenAppUser(cspCreds.CSPClientId, cspCreds.CSPAdminAgentUserName, cspCreds.CSPAdminAgentPassword, cspCreds.CSPResellerTenantID, true);

                // Create the HttpClient Object
                HttpClient client = new HttpClient();

                // Set the request header values
                client.DefaultRequestHeaders.Add("Authorization", "Bearer " + aadToken);
                client.DefaultRequestHeaders.Add("Accept", "application/json");
                client.DefaultRequestHeaders.Add("MS-CorrelationId", Guid.NewGuid().ToString());
                client.DefaultRequestHeaders.Add("MS-RequestId", Guid.NewGuid().ToString());
                client.DefaultRequestHeaders.Add("X-Locale", Constants.CSPLocale);
                client.Timeout = new TimeSpan(0, APIResponseTimeLimitConstants.RateCardFetchLimit, 0);

                // Set the path
                var path = string.Format("{0}/v1/ratecards/azure?currency={1}&region={2}", APIURLConstants.PCAPIUrl, cspCreds.CSPCurrency, cspCreds.CSPRegion);
                Uri uri  = new Uri(path);

                // Make the API Call to fetch the Rate Card
                HttpResponseMessage response = client.GetAsync(uri).Result;

                if (response.IsSuccessStatusCode)
                {
                    string   jsonResult = response.Content.ReadAsStringAsync().Result;
                    RateCard card       = JsonConvert.DeserializeObject <RateCard>(jsonResult);
                    meterList = card.Meters;
                }
                else
                {
                    string jsonResult = response.Content.ReadAsStringAsync().Result;
                    new Exception(ExceptionLogger.GenerateLoggerTextForOnlineHelperCall("CSP Rate Card", string.Format("Error while fetching the Rate Card: {0}", jsonResult)));
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(meterList);
        }
Exemplo n.º 10
0
        public bool AddRateCard(RateCard aData)
        {
            if (aData.Rate1 == null && aData.Rate2 == null && aData.Rate3 == null && aData.Rate4 == null && aData.Type == null)
            {
                return(false);
            }
            var  entity = aData.ToEntityRateCard();
            bool isDone = this.adapter.InsertDatastore(entity, "RateCard");

            ////Updating RateCards
            //arRateCards = GetListOfRateCard(true);

            return(isDone);
        }
Exemplo n.º 11
0
        public bool DeleteRateCard(RateCard aData)
        {
            if (aData.Id == null)
            {
                return(false);
            }
            Key key = aData.Id.ToKeyRateCard();

            this.adapter.DeleteDatastore(key);

            ////Updating RateCards
            //arRateCards = GetListOfRateCard(true);

            return(true);
        }
Exemplo n.º 12
0
        public bool UpdateRateCard(RateCard aData)
        {
            if (aData.Id == null && aData.Rate1 == null && aData.Rate2 == null && aData.Rate3 == null && aData.Rate4 == null && aData.Type == null)
            {
                return(false);
            }
            var entity = aData.ToEntityRateCard();

            this.adapter.UpdateDatastore(entity);

            ////Updating RateCards
            //arRateCards = GetListOfRateCard(true);

            return(true);
        }
Exemplo n.º 13
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <AppDBContent>(options => options.UseSqlServer(_confSting.GetConnectionString("DefaultConnection")));
            services.AddTransient <IAllApplications, ApplicationRepository>();
            services.AddTransient <IApplicationsCategory, CategoryRepository>();
            services.AddTransient <IAllOrders, OrdersRepository>();

            services.AddMvc();
            services.AddMvc(options => options.EnableEndpointRouting = false);

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped(sp => RateCard.GetCard(sp));
            services.AddMemoryCache();
            services.AddSession();
        }
Exemplo n.º 14
0
        public async Task <RateCard> GetRateCardData(RateCardFilterParameters rateCardFilter)
        {
            string   rateCardCacheName = string.Format(RateCardCacheNameFormat, rateCardFilter.OfferId);
            RateCard rateCardData      = MemoryCacher.GetValue(rateCardCacheName) as RateCard;

            if (rateCardData == null)
            {
                var rateCardResponseData = await RequestRateCardDataFromService(rateCardFilter);

                rateCardData = await Task.Factory.StartNew(() => JsonConvert.DeserializeObject <RateCard>(rateCardResponseData));

                //Cache the RateCardData
                MemoryCacher.Add(rateCardCacheName, rateCardData, DateTime.Now.AddHours(1));
            }

            return(rateCardData);
        }
Exemplo n.º 15
0
 public IHttpActionResult SaveRateCard(RateCard rateCard)
 {
     try
     {
         var result = new RateCardBO().SaveRateCard(rateCard);
         if (result)
         {
             return(Ok(UTILITY.SUCCESSMSG));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
Exemplo n.º 16
0
        public RateCard GetRateCardRecord(string recordID, string UserID)
        {
            SqlDataReader dr = null;

            try
            {
                RateCard       rateCard   = new RateCard();
                SqlParameter[] Parameters = { new SqlParameter("@SNo",    Convert.ToInt32(recordID)),
                                              new SqlParameter("@UserID", Convert.ToInt32(UserID)) };

                dr = SqlHelper.ExecuteReader(ReadConnectionString.WebConfigConnectionString, CommandType.StoredProcedure, "dbo.GetRateCardRecord", Parameters);

                if (dr.Read())
                {
                    rateCard.SNo          = Convert.ToInt32(recordID);
                    rateCard.RateCardName = dr["RateCardName"].ToString().ToUpper();

                    rateCard.StartDate = DateTime.Parse(dr["StartDate"].ToString());
                    rateCard.EndDate   = DateTime.Parse(dr["EndDate"].ToString());

                    rateCard.Active = dr["Active"].ToString();

                    rateCard.IsActive = Convert.ToBoolean(dr["IsActive"]);

                    rateCard.CreatedUser = dr["CreatedUser"].ToString();
                    rateCard.UpdatedUser = dr["UpdatedUser"].ToString();
                }
                dr.Close();
                return(rateCard);
            }
            catch (Exception ex)//(Exception ex)
            {
                dr.Close();
                throw ex;
            }
        }
Exemplo n.º 17
0
        private static List <ChartData> CalculateCostsForChart(List <ResourceUsage> resourceUsageHistoricalData, List <ResourceUsage> resourceUsageTodaysData, RateCard rateCard)
        {
            CostStrategyContext costStrategy = new CostStrategyContext(resourceUsageHistoricalData, resourceUsageTodaysData, rateCard);

            return(costStrategy.CalculateCostsForChart());
        }
Exemplo n.º 18
0
 public bool  addRateCard(RateCard rateCard)
 {
     return(RateCardDB.addRateCard(rateCard));
 }
Exemplo n.º 19
0
        public Invoice RequestSendingInvoice(PostInvoice aInvoice)
        {
            //Validating data
            if (aInvoice.CompanyId == null)
            {
                return(null);
            }

            //Getting company from Id
            InformationBL bl      = new InformationBL();
            Company       company = bl.GetCompanyFrom(aInvoice.CompanyId);

            if (company == null)
            {
                return(null);
            }

            //Getting active worker
            int activeWorkers = NumberOfActiveWorker(company.Table);

            //Getting rate card from Rate Type
            if (aInvoice.RateCardId != null)
            {
                company.RateCardId = aInvoice.RateCardId;
            }
            RateCard rateCard = bl.GetRateCardFromId(company.RateCardId);
            double   rate     = GetRateFrom(rateCard, activeWorkers);

            //Generating invoice unique name
            string front  = "EMP";
            string end    = null;
            int    nItems = this.adater.NumberOfGoogleStorageItems(this.bucketName);

            if (nItems.ToString("D").Length == 1)
            {
                end = "000" + nItems.ToString();
            }
            else if (nItems.ToString("D").Length == 2)
            {
                end = "00" + nItems.ToString();
            }
            else if (nItems.ToString("D").Length == 3)
            {
                end = "00" + nItems.ToString();
            }
            else
            {
                end = nItems.ToString();
            }
            string invName = front + end;    //xxxx

            //Creating invoice model
            Invoice invoice = CreateInvoice(invName, company.Name, company.Email, activeWorkers, rate);

            //Saving invoice data to company
            company.InvoiceNo           = invoice.InvoiceNo;
            company.RecentDate          = invoice.InvoiceDate;
            company.RecentActiveWorkers = activeWorkers.ToString();
            company.RecentTotal         = invoice.Total;
            company.RecentRate          = rate.ToString();
            Company updateCom = bl.UpdateCompany(company);

            if (updateCom == null)
            {
                return(null);
            }

            //Create invoice a memory stream of pdf content
            MemoryStream memory = CreateInvoiceMemoryStream(invoice);

            if (memory == null)
            {
                return(null);
            }

            //Upload the content of file to cloud
            this.adater.UploadObject(this.bucketName, invName + ".pdf", "application/pdf", memory);

            //TODO -- Should me synchronize?
            //Send mail
            EmailHandler handler = new EmailHandler();

            handler.SendMail(invoice.Company.Email, invName + ".pdf", this.adater);

            return(invoice);
        }
Exemplo n.º 20
0
 public bool SaveRateCard(RateCard newItem)
 {
     return(ratecardDAL.Save(newItem));
 }
Exemplo n.º 21
0
 public RateCard GetRateCard(RateCard item)
 {
     return((RateCard)ratecardDAL.GetItem <RateCard>(item));
 }
Exemplo n.º 22
0
 public bool DeleteRateCard(RateCard item)
 {
     return(ratecardDAL.Delete(item));
 }