public price post(price value) { using (var db = new OcphDbContext()) { try { var dataExist = db.Prices.Where(x => x.AgentId == value.AgentId && x.PortType == value.PortType).FirstOrDefault(); if (dataExist != null) { throw new SystemException($"Data Tarif ke {value.City.Name} via {value.PortType} Sudah ada"); } value.Id = db.Prices.InsertAndGetLastID(value); if (value.Id > 0) { return(value); } throw new SystemException(" Agent Tidak Berhasil Ditambah"); } catch (Exception ex) { throw new SystemException(ex.Message); } } }
public void amountOffer() { int priceLevel = 3; price sys = new price(); sys.offerAmount(priceLevel); Assert.AreNotEqual(21, sys.offerAmount(priceLevel)); }
public void nameTake() { //get the original price from the resource name price sys = new price(); string resourceName = "gold"; sys.takePrice(resourceName); Assert.AreEqual(200, sys.takePrice(resourceName)); }
public CryptoPrice MapToCryptoPrice(price price, string baseCurrency, string quoteCurrency) { return(new CryptoPrice { Value = price.value, Timestamp = price.timestamp, BaseCurrency = baseCurrency, QuoteCurrency = quoteCurrency }); }
public void priceLevel() { int offerPrice = 220; int oringinalPrice = 200; //return the computer purchase level(from 1 to 3) price sys = new price(); sys.getPriceLevel(offerPrice, oringinalPrice); Assert.AreEqual(4, sys.getPriceLevel(offerPrice, oringinalPrice)); }
// PUT: api/Agent/5 public IHttpActionResult Put(int id, [FromBody] price value) { try { return(Ok(context.Update(value))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public static void AddPrice(int idSpec, int IdUser, double pricespec) { var entity = new sovadb001Entities0(); price np = new price(); np.IdSpecialization = idSpec; np.IdTranslator = entity.translators.First(t => t.IdUser == IdUser).IdTranslator; np.price1 = pricespec; entity.prices.Add(np); entity.SaveChanges(); }
public ActionResult CreatePrice([Bind(Include = "price_version_id,product_id,product_price,version_date,price_comment")] price price) { if (ModelState.IsValid) { price.version_date = DateTime.Now; price.product_id = prodId; db.price.Add(price); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.product_id = prodId; return(View(price)); }
// POST: api/Agent public IHttpActionResult Post([FromBody] price value) { try { if (value == null) { throw new SystemException("Periksa Kembali Data Anda"); } return(Ok(context.post(value))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public static void AddTranslator(int[] idSpec, int idUser) { var entity = new sovadb001Entities0(); translator nt = new translator(); nt.countOfComplitedOrders = 0; nt.IdUser = idUser; entity.translators.Add(nt); entity.SaveChanges(); double[] p = new double[idSpec.Length]; int x = 0; foreach (int i in idSpec) { price pr = GetSpecialization(i).prices.First(t => t.IdTranslator == entity.translators.First(q => q.IdUser == idUser).IdTranslator); specialization s = GetSpecialization(i); if (pr != null) { p[x] = (double)(pr.price1 / s.complexity); } else { p[x] = 0; } x++; } double sum = 0; for (int i = 0; i < p.Length; i++) { sum += p[i]; } sum /= p.Length; double sum1 = 0; for (int i = 0; i < p.Length; i++) { if (p[i] != 0) { p[i] -= sum; p[i] = Math.Abs(p[i]); sum1 += p[i]; } } entity.translators.First(q => q.IdUser == idUser).reputation = (int)sum1; entity.SaveChanges(); }
public void CryptoPriceMapper_Maps_To_CryptoPrice() { var price = new price() { asset_id = 1, value = 1337, timestamp = new System.DateTime() }; var cryptoPriceMapper = new CryptoPriceMapper(); var result = cryptoPriceMapper.MapToCryptoPrice(price, "BTC", "USD"); Assert.AreEqual("BTC", result.BaseCurrency); Assert.AreEqual("USD", result.QuoteCurrency); Assert.AreEqual(1337, result.Value); Assert.AreEqual(new System.DateTime(), result.Timestamp); }
public static price GetPrice() { var credential = GetSheetCredentials(); var service = GetService(credential); SpreadsheetsResource.ValuesResource.GetRequest request = service.Spreadsheets.Values.Get(SpreadsheetId, "price"); price price = new price(); ValueRange response = request.Execute(); price.metro = new costCard { limit46 = int.Parse(response.Values[1][1].ToString()), limit62 = int.Parse(response.Values[1][2].ToString()), unlim = int.Parse(response.Values[1][3].ToString()) }; price.metroTram = new costCard { limit46 = int.Parse(response.Values[2][1].ToString()), limit62 = int.Parse(response.Values[2][2].ToString()), unlim = int.Parse(response.Values[2][3].ToString()) }; price.metroBus = new costCard { limit46 = int.Parse(response.Values[3][1].ToString()), limit62 = int.Parse(response.Values[3][2].ToString()), unlim = int.Parse(response.Values[3][3].ToString()) }; price.metroTroley = new costCard { limit46 = int.Parse(response.Values[4][1].ToString()), limit62 = int.Parse(response.Values[4][2].ToString()), unlim = int.Parse(response.Values[4][3].ToString()) }; return(price); }
public price Update(price value) { using (var db = new OcphDbContext()) { try { var saved = db.Prices.Update(O => new { O.PortType, O.PriceValue, O.CityId }, value, O => O.Id == value.Id); if (saved) { return(value); } throw new SystemException("Data Agent Tidak Berhasil Diubah"); } catch (Exception ex) { throw new SystemException(ex.Message); } } }
public void pricesSell_construct() { price sys = new price(); Assert.IsNotNull(sys); }
void Start() { //1.定义一个学校结构体,包含上述所有数据 //问:为什么不能写kindergarten[0].boy + kindergarten[0].girl = 30; SchoolInfo[] kindergarten = new SchoolInfo[3]; kindergarten[0].name = "大班"; kindergarten[0].total = 30; kindergarten[0].boy = kindergarten[0].girl = 15; kindergarten[1].name = "中班"; kindergarten[1].total = 36; kindergarten[1].boy = kindergarten[1].girl + 4; kindergarten[1].boy = 36 - kindergarten[1].girl; kindergarten[2].name = "小班"; kindergarten[2].total = 42; kindergarten[2].boy = kindergarten[0].total - kindergarten[2].girl; kindergarten[2].boy = 60 - kindergarten[1].boy - kindergarten[0].boy; kindergarten[2].girl = 48 - kindergarten[1].girl - kindergarten[0].girl; //2.输入参数为学校结构体,打印小班男女人数各为多少 printboygirl(kindergarten); //3.定义一个旅行社结构体,包含所有旅行社信息 travelCost[] japan = new travelCost[3]; japan[0].name = "大班"; japan[0].white = 2000; japan[0].black = 1900; japan[1].name = "中班"; japan[1].white = 2200; japan[1].black = 1900; japan[2].name = "小班"; japan[2].white = 2500; japan[2].black = 1900; //4.编写一个函数,传参为学校结构体和旅行社结构体,求出园长妈妈吃了多少回扣 printMoney(japan, kindergarten); //5.定义武器结构体,包含上述所有武器信息,实例化红光剑和蓝光盾。 Weapon red; Weapon blue; red.name = "红光剑"; red.length = 2.0f; red.width = 0.4f; red.attack = 80; red.defence = 20; blue.name = "蓝光盾"; blue.length = 1.5f; blue.width = 1.5f; blue.attack = 30; blue.defence = 90; //6.编写一个函数,传参为红光剑和蓝光盾,求出两个武器的面积之和。 addarea(red, blue); //7.假设有个坏人血量为1000 ,求出Hank大喊:“红光之力攻击!”后,编写一个函数打印如下数据:坏人剩余血量,蓝光盾的护值。 attackred(red, blue, 1000); //8.定义喜翠瓶在每一代的价格结构体 price[] xicui = new price[14]; xicui[0].generation = "四十万一代"; xicui[0].jpy = 4000; xicui[1].jpy = xicui[0].jpy / 2; xicui[2].jpy = xicui[1].jpy * 10; xicui[3].jpy = xicui[2].jpy; //9.假设喜翠瓶在第四代之后,每年价值翻倍,编写一个函数,传入参数为喜翠瓶价格结构体,填充结构体数据,打印喜翠瓶在每一代人手中的价格. printprice(xicui); //10.编写一个函数,传入学校结构体,旅行社结构体及喜翠瓶价格结构体,求出园长妈妈最终的盈亏。 PI(kindergarten, japan, xicui); }
=> Apply(new ProductCreated(ProductId, name, price, description));
protected void load_info_Click(object sender, EventArgs e) { Label1.Text = ""; onenote one = new onenote(); string txt_grade = ""; string txt_cpu = ""; string txt_hdd = ""; string txt_ic = ""; string txt_ram = ""; des.Text = ""; soft_des.Text = ""; short_des.Text = ""; string serial = ""; if (Page.IsValid) { MySql.Data.MySqlClient.MySqlConnection mySqlConnection = new MySql.Data.MySqlClient.MySqlConnection(); mySqlConnection.ConnectionString = "server=us-cdbr-azure-west-c.cloudapp.net;uid=b9067d3066d876;pwd=4d1a509d;database=ic_database"; MySqlCommand cmd2 = new MySqlCommand("select * from rediscovery where ictag='" + asset_tag.Text + "'", mySqlConnection); mySqlConnection.Open(); MySqlDataReader reader = cmd2.ExecuteReader(); while (reader.Read()) { sku_family.Text = reader["pallet"].ToString(); serial = reader["serial"].ToString(); } mySqlConnection.Close(); if (serial != "") { // connection to next database file mySqlConnection.Open(); cmd2 = new MySqlCommand("select * from production_log where serial='" + serial + "'", mySqlConnection); reader = cmd2.ExecuteReader(); while (reader.Read()) //read every data { wcoa.Text = reader["wcoa"].ToString(); ocoa.Text = reader["ocoa"].ToString(); video_card.Text = reader["video_card"].ToString(); screen.Text = (reader["screen_size"].ToString()); model = reader["Model"].ToString(); Session["model"] = model; brand.Text = reader["Manufacture"].ToString(); cpu.Text = reader["CPU"].ToString(); //ram info roundup ram.Text = reader["RAM"].ToString(); ram.Text = ram.Text.Replace("MB", ""); double temp_ram = double.Parse(ram.Text); temp_ram = temp_ram / 1000; ram.Text = Math.Round(temp_ram).ToString() + "GB"; //hdd info roundup hdd.Text = reader["HDD"].ToString(); hdd.Text = hdd.Text.Replace("GB", ""); int temp_hdd = int.Parse(hdd.Text); if (temp_hdd >= 0 && temp_hdd <= 80) { hdd.Text = "80GB"; } else if (temp_hdd >= 81 && temp_hdd <= 120) { hdd.Text = "120GB"; } else if (temp_hdd >= 121 && temp_hdd <= 160) { hdd.Text = "160GB"; } else if (temp_hdd >= 161 && temp_hdd <= 250) { hdd.Text = "250GB"; } else if (temp_hdd >= 251 && temp_hdd <= 320) { hdd.Text = "320GB"; } else if (temp_hdd >= 321 && temp_hdd <= 500) { hdd.Text = "500GB"; } else if (temp_hdd >= 501 && temp_hdd <= 610) { hdd.Text = "610GB"; } else if (temp_hdd >= 611 && temp_hdd <= 750) { hdd.Text = "750GB"; } else if (temp_hdd >= 751 && temp_hdd <= 1000) { hdd_price = "1000GB"; hdd.Text = "1TB"; } else if (temp_hdd >= 1001 && temp_hdd <= 1500) { hdd_price = "1500GB"; hdd.Text = "1.5TB"; } else if (temp_hdd >= 1501 && temp_hdd <= 2000) { hdd_price = "2000GB"; hdd.Text = "2TB"; } } mySqlConnection.Close(); } else { Label1.Text = "Fail to Query Database serial is empty or null"; return; } } pc_type_selection(); software_selection(); txt_grade = one.grade_filter(sku_family.Text, grade.SelectedValue); txt_cpu = one.cpu_filter(cpu.Text); txt_hdd = one.hdd_filter(hdd.Text); txt_ram = one.ram_filter(ram.Text); txt_ic = one.ic_filter(); des.Text = txt_grade + txt_cpu + txt_hdd + txt_ram + txt_ic; meta_info.Text = name.Text + " with " + software.Text; channel_filter(); price price = new price(); if (hdd.Text.Contains("TB")) { if (screen.Text == "") { screen.Text = "0"; } price_control.Text = price.base_spec(sku_family.Text, ram.Text, hdd_price, cpu.Text, grade.SelectedItem.Value, screen.Text); } else { if (screen.Text == "") { screen.Text = "0"; } if (screen.Text == "NA") { screen.Text = "0"; } double temp_screen = double.Parse(screen.Text); screen.Text = Math.Round(temp_screen).ToString(); price_control.Text = price.base_spec(sku_family.Text, ram.Text, hdd.Text, cpu.Text, grade.SelectedItem.Value, screen.Text); } // fetch_photo(); }
static void Main(string[] args) { int menu; Console.WriteLine("Введите количество товаров:"); int n = Convert.ToInt32(Console.ReadLine()); price[] a = new price[n]; while (true) { Console.WriteLine(); Console.WriteLine("Нажмите 1 чтобы внести базу"); Console.WriteLine("Нажмите 2 чтобы отсортировать в алфавитном порядке"); Console.WriteLine("нажмите 3 чтобы найти товар и информацию о нем"); Console.WriteLine("нажмите 4 чтобы вывести"); Console.WriteLine("нажмите 5 для выхода"); menu = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(); switch (menu) { case 1: for (int i = 0; i < n; i++) { Console.Write("Введите название товара ОДИН символ:"); a[i].name = Convert.ToChar(Console.ReadLine()); Console.Write("Введите название магазина ОДИН символ:"); a[i].nameshop = Convert.ToChar(Console.ReadLine()); Console.WriteLine("Стоимость товара:"); a[i].st = Convert.ToDecimal(Console.ReadLine()); } break; case 2: char a1; char a2; decimal a3; for (int i = 0; i < n - 1; i++) for (int j = 0; j < n - i - 1; j++) if (a[j].name > a[j + 1].name) { /*******************/ a1 = a[j].name; a[j].name = a[j + 1].name; a[j + 1].name = a1; /*******************/ a2 = a[j].nameshop; a[j].nameshop = a[j + 1].nameshop; a[j + 1].nameshop = a2; /*******************/ a3 = a[j].st; a[j].st = a[j + 1].st; a[j + 1].st = a3; } Console.WriteLine(); Console.WriteLine("Отсортировано!!!"); Console.WriteLine(); break; case 3: bool f = false; char c; Console.WriteLine("Введите название товара"); c = Convert.ToChar(Console.ReadLine()); for (int i = 0; i < n; i++) if (c == a[i].name) { f = true; Console.WriteLine("Название {0}, в магазине {1}, стоимость {2}", a[i].name, a[i].nameshop, a[i].st); } if (f == false) { Console.WriteLine(); Console.WriteLine("Нет такого товара!!!"); Console.WriteLine(); } break; case 4: for (int i = 0; i < n; i++) Console.WriteLine("Товар {0},В магазине {1},Стоимость {2}", a[i].name, a[i].nameshop, a[i].st); Console.WriteLine(); break; case 5: return; default: Console.WriteLine(); Console.WriteLine("ERRORE"); Console.WriteLine(); break; } } }
public void Awake() { instance = this; }