public ActionResult PriceList_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<PriceModel> products) { if (products != null && ModelState.IsValid) { foreach (var product in products) { if (product.Id == 0) { PriceList price = new PriceList(); price.CreditVolume = product.CreditVolume; price.CreditPriceNaira = product.CreditPriceNaira; price.DollarCredit = product.DollarCredit; _genservice.savePriceList(price); } } } var importname = _genservice.GetPriceList(); var list = importname.Select(x => new PriceModel { Id = x.Id, CreditVolume = x.CreditVolume, CreditPriceNaira = x.CreditPriceNaira, DollarCredit = x.DollarCredit, }); return Json(list.ToDataSourceResult(request, ModelState)); }
public ActionResult Create(PriceList item) { if (!ModelState.IsValid) return PartialView ("_Create", item); item.LowProfitMargin /= 100m; item.HighProfitMargin /= 100m; using (var scope = new TransactionScope ()) { item.CreateAndFlush (); } return PartialView ("_CreateSuccesful", item); }
public static PriceList GetOrAdd(int goodsId, int userId, string equipmentCode, PriceList goodsPriceList, Func<int, int, string, PriceList> valueFactory) { var token = goodsPriceList.Token; var list = GoodsUserCacheBox.GetDataFromCache(goodsId, token, userId, equipmentCode); if (list == null) { list = valueFactory(goodsId, userId, equipmentCode); if (list != null) { Set(userId, equipmentCode, token, list); } } return list; }
static void Main(string[] args) { PriceList[] pricelist = new PriceList[50]; DateTime[] dateTimes = new DateTime[50]; string[] explainer = new string[50]; int pos = 3; pricelist[0].nameofprod = "Папка"; pricelist[0].type = EnumType.K; pricelist[0].price = 4.75; pricelist[0].quantity = 400; pricelist[1].nameofprod = "Бумага A4 (пачка)"; pricelist[1].type = EnumType.K; pricelist[1].price = 45.90; pricelist[1].quantity = 100; pricelist[2].nameofprod = "Калькулятор"; pricelist[2].type = EnumType.O; pricelist[2].price = 411.00; pricelist[2].quantity = 10; if (!File.Exists(@"C:\Users\USER\Desktop\Lab6\Number1(6)\lab.dat")) { FileStream fss = new FileStream(@"C:\Users\USER\Desktop\Lab6\Number1(6)\lab.dat", FileMode.Create); BinaryWriter biwriter = new BinaryWriter(fss); biwriter.Write(pricelist[0].nameofprod); biwriter.Write(pricelist[0].type.ToString()); biwriter.Write(pricelist[0].price); biwriter.Write(pricelist[0].quantity); biwriter.Write(pricelist[1].nameofprod); biwriter.Write(pricelist[1].type.ToString()); biwriter.Write(pricelist[1].price); biwriter.Write(pricelist[1].quantity); biwriter.Write(pricelist[2].nameofprod); biwriter.Write(pricelist[2].type.ToString()); biwriter.Write(pricelist[2].price); biwriter.Write(pricelist[2].quantity); biwriter.Close(); } else { bool mark = true; int datepos = 0; while (mark) { Console.WriteLine("1 - Просмотр таблицы\n2 - Добавить запись\n3 - Удалить запись\n4 - Обновить запись\n5 - Поиск записей\n6 - Просмотреть лог\n7 - Выход"); string inpusolution = Console.ReadLine(); switch (inpusolution) { case "1": Console.Clear(); Console.WriteLine(File.ReadAllText(@"C:\Users\USER\Desktop\Lab6\Number1(6)\lab.dat")); Console.ReadKey(); Console.Clear(); break; case "2": Console.Clear(); Console.WriteLine("Введите наименование товара: "); pricelist[pos].nameofprod = Console.ReadLine(); Console.WriteLine("Введите тип товара: "); pricelist[pos].type = (EnumType)Enum.Parse(typeof(EnumType), Console.ReadLine()); Console.WriteLine("Введите Цена за 1 шт (грн): "); pricelist[pos].price = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Введите количество товара: "); pricelist[pos].quantity = Convert.ToInt32(Console.ReadLine()); dateTimes[datepos] = DateTime.Now; string addnote = pricelist[3].nameofprod; explainer[datepos] = $"запись добавлена \"{addnote}\""; datepos++; pos++; Console.Clear(); break; case "3": Console.Clear(); Console.WriteLine("Введите номер удаляемой записи: "); int numdel = Convert.ToInt32(Console.ReadLine()); string numrec = pricelist[numdel].nameofprod; explainer[datepos] = $"запись удалена \"{numrec}\""; for (int i = numdel; i < pos; i++) { pricelist[i].nameofprod = pricelist[i + 1].nameofprod; pricelist[i].type = pricelist[i + 1].type; pricelist[i].price = pricelist[i + 1].price; pricelist[i].quantity = pricelist[i + 1].quantity; } pos--; dateTimes[datepos] = DateTime.Now; datepos++; Console.Clear(); break; case "4": Console.Clear(); Console.WriteLine("Введите номер редактируемой записи: "); int numberred = Convert.ToInt32(Console.ReadLine()); string postupdated = pricelist[numberred].nameofprod; Console.WriteLine("Введите новое наименование товара: "); pricelist[numberred].nameofprod = Console.ReadLine(); Console.WriteLine("Введите новый тип товара: "); pricelist[numberred].type = (EnumType)Enum.Parse(typeof(EnumType), Console.ReadLine()); Console.WriteLine("Введите новую Цену за 1 шт (грн):"); pricelist[numberred].price = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Введите новое количество товара: "); pricelist[numberred].quantity = Convert.ToInt32(Console.ReadLine()); dateTimes[datepos] = DateTime.Now; explainer[datepos] = $"запись обновлена \"{postupdated}\""; datepos++; Console.Clear(); break; case "5": Console.Clear(); Console.WriteLine("Введите минимальную цену: "); double minprice = Convert.ToDouble(Console.ReadLine()); for (int i = 0; i < pos; i++) { if (pricelist[i].price > minprice) { Console.WriteLine($"{pricelist[i].nameofprod,-20}|{pricelist[i].type,-15}|{pricelist[i].price,-10}|{pricelist[i].quantity,-10}"); } } Console.ReadLine(); Console.Clear(); break; case "6": Console.Clear(); TimeSpan longperiodinactivity = dateTimes[1].Subtract(dateTimes[0]); for (int i = 0; i < datepos; i++) { Console.WriteLine($"{dateTimes[i].Hour}:{dateTimes[i].Minute}:{dateTimes[i].Second} - {explainer[i]}"); if ((dateTimes[i + 1].Subtract(dateTimes[i])) > longperiodinactivity) { longperiodinactivity = dateTimes[i + 1].Subtract(dateTimes[i]); } } Console.WriteLine(); Console.WriteLine($"{longperiodinactivity.Hours}:{longperiodinactivity.Minutes}:{longperiodinactivity.Seconds} - Наибольший период бездействия пользователя."); Console.ReadLine(); Console.Clear(); break; case "7": FileStream lastfile = new FileStream(@"C:\Users\USER\Desktop\Lab6\Number1(6)\lab.dat", FileMode.Open); BinaryWriter biwrite = new BinaryWriter(lastfile); for (int i = 0; i < pos; i++) { biwrite.Write(pricelist[i].nameofprod); biwrite.Write(pricelist[i].type.ToString()); biwrite.Write(pricelist[i].price); biwrite.Write(pricelist[i].quantity); } biwrite.Close(); mark = false; break; default: Console.Clear(); break; } } } }
public override void Analysis(CurrentPrice price) { try { switch (ruleInfo.PriceType) { case "0": CPrice = Math.Round(Convert.ToDouble(price.price), RoundNum); break; case "1": CPrice = Math.Round(price.price3, RoundNum); break; case "2": CPrice = Math.Round(price.price5, RoundNum); break; case "3": CPrice = Math.Round(price.price7, RoundNum); break; default: CPrice = Math.Round(Convert.ToDouble(price.price), RoundNum); break; } if (BPrice == CPrice) { return; } if (HPrice < CPrice) { HPrice = Math.Round(CPrice, RoundNum); } if (LPrice > CPrice) { LPrice = Math.Round(CPrice, RoundNum); } PriceList.Insert(CPrice); double basePrice = Math.Round(Convert.ToDouble(ruleInfo.BasePrice), RoundNum); double buyPrice = Math.Round(GetBuyPrice(basePrice), RoundNum); if (ruleInfo.IsUse == "N") { return; } if (buyPrice == 0) { return; } // 진입 if (!ruleInfo.IsBuyDone) { //기준가 터치여부 체크 if (!ruleInfo.IsTouchedBasePrice) { if (ruleInfo.Position == "매수") { if (basePrice <= CPrice) { ruleInfo.IsTouchedBasePrice = true; ruleInfo.BasePriceTouchTime = DateTime.Now; } } else if (ruleInfo.Position == "매도") { if (basePrice >= CPrice) { ruleInfo.IsTouchedBasePrice = true; ruleInfo.BasePriceTouchTime = DateTime.Now; } } } //매입여부 체크 if (ruleInfo.IsTouchedBasePrice) { //기준가 터치후 제약시간이상 넘었을 경우 if (ruleInfo.BuyLimitTime != 0 && ruleInfo.BasePriceTouchTime.AddMinutes(ruleInfo.BuyLimitTime) < DateTime.Now) { ruleInfo.IsUse = "N"; return; } if (ruleInfo.Position == "매수") { if (buyPrice >= CPrice) { //매수진입 ruleInfo.IsBuyDone = true; ruleInfo.BuyedTime = DateTime.Now; SellBuy("신규매입", "매수"); } } else if (ruleInfo.Position == "매도") { if (buyPrice <= CPrice) { //매도진입 ruleInfo.IsBuyDone = true; ruleInfo.BuyedTime = DateTime.Now; SellBuy("신규매입", "매도"); } } } } if (!ruleInfo.IsBuyDone) { return; } //손실체크 double lossPrice = Math.Round(GetLossPrice(basePrice), RoundNum); if (lossPrice > 0 && ruleInfo.IsBuyDone) { if (ruleInfo.Position == "매수") { if (lossPrice >= CPrice) { //매도진입 InitRule(); SellBuy("손실청산", "매도"); } } else if (ruleInfo.Position == "매도") { if (lossPrice <= CPrice) { //매수진입 InitRule(); SellBuy("손실청산", "매수"); } } } //수익체크 double revenuePrice = Math.Round(GetRevenuePrice(basePrice), RoundNum); if (revenuePrice > 0 && ruleInfo.IsBuyDone) { if (ruleInfo.RevenueLimitTime != 0 && ruleInfo.BuyedTime.AddMinutes(ruleInfo.RevenueLimitTime) < DateTime.Now) { //강제청산 if (ruleInfo.Position == "매수") { //매도진입 InitRule(); SellBuy("수익강제청산", "매도"); } else if (ruleInfo.Position == "매도") { //매수진입 InitRule(); SellBuy("수익강제청산", "매수"); } } else { if (ruleInfo.Position == "매수") { if (revenuePrice <= CPrice) { //매도진입 InitRule(); SellBuy("수익청산", "매도"); } } else if (ruleInfo.Position == "매도") { if (revenuePrice >= CPrice) { //매수진입 InitRule(); SellBuy("수익청산", "매수"); } } } } } catch (Exception) { } finally { BPrice = CPrice; } }
public virtual void UpdatePriceList(PriceList entity) { Update(entity); }
public SubscriptionPaymentTestData(PriceList priceList, PayerId payerId, SubscriptionId subscriptionId) { PriceList = priceList; PayerId = payerId; SubscriptionId = subscriptionId; }
public void CreatePriceList(PriceList priceList) { PriceListMgr.CreatePriceList(priceList); }
protected override void Seed(WebApp.Persistence.ApplicationDbContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. // System.Diagnostics.Debugger.Launch(); try { // UserType if (!context.UserType.Any(u => u.Name == "Đak")) { UserType userType = new UserType() { Name = "Đak", Id = 1 }; context.UserType.Add(userType); context.SaveChanges(); } if (!context.UserType.Any(u => u.Name == "Penzioner")) { UserType userType = new UserType() { Name = "Penzioner", Id = 2 }; context.UserType.Add(userType); context.SaveChanges(); } if (!context.UserType.Any(u => u.Name == "Regularan")) { UserType userType = new UserType() { Name = "Regularan", Id = 3 }; context.UserType.Add(userType); context.SaveChanges(); } if (!context.Roles.Any(r => r.Name == "Admin")) { var store = new RoleStore <IdentityRole>(context); var manager = new RoleManager <IdentityRole>(store); var role = new IdentityRole { Name = "Admin" }; manager.Create(role); } if (!context.Roles.Any(r => r.Name == "Controller")) { var store = new RoleStore <IdentityRole>(context); var manager = new RoleManager <IdentityRole>(store); var role = new IdentityRole { Name = "Controller" }; manager.Create(role); } if (!context.Roles.Any(r => r.Name == "AppUser")) { var store = new RoleStore <IdentityRole>(context); var manager = new RoleManager <IdentityRole>(store); var role = new IdentityRole { Name = "AppUser" }; manager.Create(role); } var userStore = new UserStore <ApplicationUser>(context); var userManager = new UserManager <ApplicationUser>(userStore); if (!context.Users.Any(u => u.UserName == "*****@*****.**")) { var user = new ApplicationUser() { Id = "admin", UserName = "******", Email = "*****@*****.**", PasswordHash = ApplicationUser.HashPassword("Admin123!"), TypeId = 2 }; userManager.Create(user); userManager.AddToRole(user.Id, "Admin"); } if (!context.Users.Any(u => u.UserName == "*****@*****.**")) { var user = new ApplicationUser() { Id = "controller", UserName = "******", Email = "*****@*****.**", PasswordHash = ApplicationUser.HashPassword("Controller123!"), TypeId = 2 }; userManager.Create(user); userManager.AddToRole(user.Id, "Controller"); } if (!context.Users.Any(u => u.UserName == "appu@yahoo")) { var user = new ApplicationUser() { Id = "appu", UserName = "******", Email = "*****@*****.**", PasswordHash = ApplicationUser.HashPassword("Appu123!"), TypeId = 2 }; userManager.Create(user); userManager.AddToRole(user.Id, "AppUser"); } // Ticket type if (!context.TicketType.Any(t => t.Name == "Vremenska karta")) { TicketType ticketType = new TicketType() { Name = "Vremenska karta", Id = 1 }; context.TicketType.Add(ticketType); try { context.SaveChanges(); } catch (DbEntityValidationException e) { //foreach (var eve in e.EntityValidationErrors) //{ // Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", // eve.Entry.Entity.GetType().Name, eve.Entry.State); // foreach (var ve in eve.ValidationErrors) // { // Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", // ve.PropertyName, ve.ErrorMessage); // } //} //throw; var outputLines = new List <string>(); foreach (var eve in e.EntityValidationErrors) { outputLines.Add(string.Format( "{0}: Entity of type \"{1}\" in state \"{2}\" has the following validation errors:", DateTime.Now, eve.Entry.Entity.GetType().Name, eve.Entry.State)); foreach (var ve in eve.ValidationErrors) { outputLines.Add(string.Format( "- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage)); } } // asasdasd System.IO.File.AppendAllLines(@"c:\errors.txt", outputLines); throw; } } if (!context.TicketType.Any(t => t.Name == "Dnevna karta")) { TicketType ticketType = new TicketType() { Name = "Dnevna karta", Id = 2 }; context.TicketType.Add(ticketType); context.SaveChanges(); } if (!context.TicketType.Any(t => t.Name == "Mesečna karta")) { TicketType ticketType = new TicketType() { Name = "Mesečna karta", Id = 3 }; context.TicketType.Add(ticketType); context.SaveChanges(); } if (!context.TicketType.Any(t => t.Name == "Godišnja karta")) { TicketType ticketType = new TicketType() { Name = "Godišnja karta", Id = 4 }; context.TicketType.Add(ticketType); context.SaveChanges(); } // Pricelist if (!context.Pricelist.Any(t => t.Id == 1)) { PriceList pricelist = new PriceList() { Id = 1, From = DateTime.Now.ToString(), To = DateTime.Now.ToString() }; context.Pricelist.Add(pricelist); context.SaveChanges(); } if (!context.Pricelist.Any(t => t.Id == 2)) { PriceList pricelist = new PriceList() { Id = 2, From = DateTime.Now.ToString(), To = DateTime.Now.ToString() }; } if (!context.Pricelist.Any(t => t.Id == 3)) { PriceList pricelist = new PriceList() { Id = 3, From = DateTime.Now.ToString(), To = DateTime.Now.ToString() }; context.Pricelist.Add(pricelist); context.SaveChanges(); } if (!context.Pricelist.Any(t => t.Id == 4)) { PriceList pricelist = new PriceList() { Id = 4, From = DateTime.Now.ToString(), To = DateTime.Now.ToString() }; context.Pricelist.Add(pricelist); context.SaveChanges(); } // ticketPrice if (!context.TicketPrice.Any(t => t.Id == 1)) { TicketPrice ticketPrice = new TicketPrice() { Price = 50, PricelistId = 1, TicketTypeId = 1 }; context.TicketPrice.Add(ticketPrice); context.SaveChanges(); } if (!context.TicketPrice.Any(t => t.Id == 2)) { TicketPrice ticketPrice = new TicketPrice() { Price = 250, PricelistId = 2, TicketTypeId = 2 }; context.TicketPrice.Add(ticketPrice); context.SaveChanges(); } if (!context.TicketPrice.Any(t => t.Id == 3)) { TicketPrice ticketPrice = new TicketPrice() { Price = 1500, PricelistId = 3, TicketTypeId = 3 }; context.TicketPrice.Add(ticketPrice); context.SaveChanges(); } if (!context.TicketPrice.Any(t => t.Id == 4)) { TicketPrice ticketPrice = new TicketPrice() { Price = 4500, PricelistId = 4, TicketTypeId = 4 }; context.TicketPrice.Add(ticketPrice); context.SaveChanges(); } // Lines if (!context.Line.Any(t => t.Id == 1)) { Line line = new Line() { Id = 1, SerialNumber = 1 }; context.Line.Add(line); context.SaveChanges(); } if (!context.Line.Any(t => t.Id == 2)) { Line line = new Line() { Id = 2, SerialNumber = 2 }; context.Line.Add(line); context.SaveChanges(); } if (!context.Line.Any(t => t.Id == 3)) { Line line = new Line() { Id = 3, SerialNumber = 3 }; context.Line.Add(line); context.SaveChanges(); } if (!context.Line.Any(t => t.Id == 4)) { Line line = new Line() { Id = 4, SerialNumber = 4 }; context.Line.Add(line); context.SaveChanges(); } if (!context.Line.Any(t => t.Id == 5)) { Line line = new Line() { Id = 5, SerialNumber = 5 }; context.Line.Add(line); context.SaveChanges(); } // Stations if (!context.Station.Any(t => t.Name == "Prva")) { Station station = new Station() { Id = 1, Name = "Prva", Address = "Adresa Prve" }; context.Station.Add(station); context.SaveChanges(); } if (!context.Station.Any(t => t.Name == "Druga")) { Station station = new Station() { Id = 1, Name = "Prva", Address = "Adresa Druge" }; context.Station.Add(station); context.SaveChanges(); } // Timetable if (!context.TimeTable.Any(t => t.Id == 1)) { TimeTable timetable = new TimeTable() { Id = 1, BusLineId = 1, TimetableTypeId = 1, DayTypeId = 1, Times = "9:50 10:50 11:50" }; context.TimeTable.Add(timetable); context.SaveChanges(); } if (!context.TimeTable.Any(t => t.Id == 2)) { TimeTable timetable = new TimeTable() { Id = 2, BusLineId = 2, TimetableTypeId = 2, DayTypeId = 2, Times = "9:30 10:30 11:30 12:30 13:30" }; context.TimeTable.Add(timetable); context.SaveChanges(); } if (!context.TimeTable.Any(t => t.Id == 3)) { TimeTable timetable = new TimeTable() { Id = 3, BusLineId = 1, TimetableTypeId = 1, DayTypeId = 2, Times = "9:10 10:10 11:10 12:10 13:10" }; context.TimeTable.Add(timetable); context.SaveChanges(); } } catch (DbEntityValidationException e) { //foreach (var eve in e.EntityValidationErrors) //{ // Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", // eve.Entry.Entity.GetType().Name, eve.Entry.State); // foreach (var ve in eve.ValidationErrors) // { // Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", // ve.PropertyName, ve.ErrorMessage); // } //} //throw; var outputLines = new List <string>(); foreach (var eve in e.EntityValidationErrors) { outputLines.Add(string.Format( "{0}: Entity of type \"{1}\" in state \"{2}\" has the following validation errors:", DateTime.Now, eve.Entry.Entity.GetType().Name, eve.Entry.State)); foreach (var ve in eve.ValidationErrors) { outputLines.Add(string.Format( "- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage)); } } // asasdasd System.IO.File.AppendAllLines(@"C:\Users\Stefan\errors.txt", outputLines); throw; } }
public string Update(PriceList entity) { entity.ModifiedOn = DateTime.Now; entity.ModifiedBy = UserInfoBLL.GetCurrentUserGuid(); return(entity.Update().ToString()); }
public virtual void UpdatePriceList(PriceList entity) { entityDao.UpdatePriceList(entity); }
public GroupLoader(bool clearData) { _context = new CubeDbContext(null, clearData); _defaultPriceList = _context.PriceLists.FirstOrDefault(); }
public ActionResult Edit(PriceList item) { if (!ModelState.IsValid) return PartialView ("_Edit", item); var entity = PriceList.Find (item.Id); entity.Name = item.Name; entity.LowProfitMargin = item.LowProfitMargin; entity.HighProfitMargin = item.HighProfitMargin; entity.LowProfitMargin /= 100m; entity.HighProfitMargin /= 100m; using (var scope = new TransactionScope ()) { entity.UpdateAndFlush (); } return PartialView ("_Refresh"); }
protected virtual void InitParts() { coinStorage = new CoinStorage(); returnStorage = new CoinStorage(); goodStorage = new GoodsStorage(); display = new Display(); avaliableCoins = new List<Coin>(); prices = new PriceList(); }
private static void Set(int userId, string equipmentCode, string token, PriceList list) { GoodsUserCacheBox.SetDataToCache(list, list.GoodsId, token, userId, equipmentCode); }
private static void Set(PriceList list) { GoodsCacheBox.SetDataToCache(list, list.GoodsId); }
public void UpdatePriceList(PriceList priceList) { PriceListMgr.UpdatePriceList(priceList); }
public void DeletePriceList(PriceList priceList) { PriceListMgr.DeletePriceList(priceList); }
public static void Initialize(FMSContext context) { context.Database.EnsureCreated(); var random = new Random(); #region products module // product statuses var status1 = new ProductStatus { Name = "Aktiivne" }; var status2 = new ProductStatus { Name = "Lõpetatud" }; // product materials var material1 = new ProductMaterial { Name = "Kuld" }; var material2 = new ProductMaterial { Name = "Hõbe" }; // product source types var sourceType1 = new ProductSourceType { Name = "Toodang" }; var sourceType2 = new ProductSourceType { Name = "Ost" }; // product destination types var destType1 = new ProductDestinationType { Name = "Sortiment" }; var destType2 = new ProductDestinationType { Name = "Allhange" }; var destType3 = new ProductDestinationType { Name = "Eritellimus" }; // product types var productTypes = new ProductType[] { new ProductType { Name = "Ehted" }, new ProductType { Name = "Lauariistad" }, new ProductType { Name = "Lauanõud" } }; context.AddRange(productTypes); context.SaveChanges(); // product groups var group1 = new ProductGroup { Name = "Sõrmus", ProductTypeId = 1 }; var group2 = new ProductGroup { Name = "Kõrvarõngad", ProductTypeId = 1 }; var group3 = new ProductGroup { Name = "Ripats", ProductTypeId = 1 }; var productGroups = new ProductGroup[] { group1, group2, group3, new ProductGroup { Name = "Lauanuga", ProductTypeId = 2 }, new ProductGroup { Name = "Lauakahvel", ProductTypeId = 2 }, new ProductGroup { Name = "Küünlajalg", ProductTypeId = 3 }, new ProductGroup { Name = "Konjakipokaal", ProductTypeId = 3 } }; context.AddRange(productGroups); context.SaveChanges(); // product brands var productBrands = new ProductBrand[] { new ProductBrand { Name = "Lummus" }, new ProductBrand { Name = "Juveel teemant " }, new ProductBrand { Name = "Kohinoor" } }; context.AddRange(productBrands); context.SaveChanges(); // product collections var productCollections = new ProductCollection[] { new ProductCollection { Name = "Aastasada", ProductBrandId = 1 }, new ProductCollection { Name = "Aovalgus", ProductBrandId = 1 }, new ProductCollection { Name = "Võsailu", ProductBrandId = 1 } }; context.AddRange(productCollections); context.SaveChanges(); // product variant types var variantTypeRing = new ProductVariantType { Name = "Sõrmuse suurus" }; var variantTypes = new ProductVariantType[] { variantTypeRing, new ProductVariantType { Name = "Kaelaketi pikkus" }, new ProductVariantType { Name = "Käeketi pikkus" } }; context.AddRange(variantTypes); context.SaveChanges(); // product variants var variants = new ProductVariant[] { new ProductVariant { Code = "165", Name = "suurus 16,5", ProductVariantType = variantTypeRing }, new ProductVariant { Code = "170", Name = "suurus 17,0", ProductVariantType = variantTypeRing }, new ProductVariant { Code = "175", Name = "suurus 17,5", ProductVariantType = variantTypeRing }, new ProductVariant { Code = "190", Name = "suurus 19,0", ProductVariantType = variantTypeRing }, }; context.AddRange(variants); context.SaveChanges(); // 27 product bases var productBases = new ProductBase[] { new ProductBase { Code = "00020073", Name = "Sõrmus nat. safiir", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 1, ProductCollectionId = 2, ProductVariantType = variantTypeRing }, new ProductBase { Code = "00020282", Name = "Sõrmus naturaalne safiir, teemant", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType2, ProductDestinationType = destType2, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 2, ProductVariantType = variantTypeRing }, new ProductBase { Code = "00020355", Name = "Sõrmus naturaalne granaat", ProductStatus = status2, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 1, ProductCollectionId = 2, ProductVariantType = variantTypeRing }, new ProductBase { Code = "00020446", Name = "Sõrmus pärl valge", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 1, ProductCollectionId = 3, ProductVariantType = variantTypeRing }, new ProductBase { Code = "00020616", Name = "Sõrmus nat. granaat", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType2, ProductDestinationType = destType1, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 1, ProductCollectionId = 2, ProductVariantType = variantTypeRing }, new ProductBase { Code = "00020829", Name = "Sõrmus naturaalne granaat", ProductStatus = status2, ProductMaterial = material2, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 1, ProductCollectionId = 2, ProductVariantType = variantTypeRing }, new ProductBase { Code = "00021477", Name = "Sõrmus valge pärl", ProductStatus = status2, ProductMaterial = material1, ProductSourceType = sourceType2, ProductDestinationType = destType1, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 1, ProductCollectionId = 3, ProductVariantType = variantTypeRing }, new ProductBase { Code = "00021526", Name = "Sõrmus naturaalne smaragd", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType2, ProductDestinationType = destType1, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 1, ProductCollectionId = 2, ProductVariantType = variantTypeRing }, new ProductBase { Code = "00021679", Name = "Sõrmus nat. topaas", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 1, ProductCollectionId = 2, ProductVariantType = variantTypeRing }, new ProductBase { Code = "00022261", Name = "Sõrmus nat. granaat", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType3, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 1, ProductCollectionId = 2, ProductVariantType = variantTypeRing }, new ProductBase { Code = "03020916", Name = "Sõrmus sünt. aleksandriit", ProductStatus = status2, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 1, ProductCollectionId = 1, ProductVariantType = variantTypeRing }, new ProductBase { Code = "03021035", Name = "Sõrmus CZ must", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType2, ProductDestinationType = destType1, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 3, ProductVariantType = variantTypeRing }, new ProductBase { Code = "03021717", Name = "Sõrmus sünt. ametüst", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType2, ProductDestinationType = destType2, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 1, ProductCollectionId = 1, ProductVariantType = variantTypeRing }, new ProductBase { Code = "03022187", Name = "Sõrmus CZ", ProductStatus = status2, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 3, ProductVariantType = variantTypeRing }, new ProductBase { Code = "03022335", Name = "Sõrmus sünt. aleksandriit", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group1.ProductTypeId, ProductGroup = group1, ProductBrandId = 1, ProductCollectionId = 1, ProductVariantType = variantTypeRing }, new ProductBase { Code = "03030232", Name = "Kõrvarõngad CZ valge", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType2, ProductDestinationType = destType3, ProductTypeId = group2.ProductTypeId, ProductGroup = group2, ProductBrandId = 3 }, new ProductBase { Code = "03030796", Name = "Kõrvarõngad CZ valge", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType2, ProductDestinationType = destType1, ProductTypeId = group2.ProductTypeId, ProductGroup = group2, ProductBrandId = 3 }, new ProductBase { Code = "03031077", Name = "Kõrvarõngad CZ shampanja", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group2.ProductTypeId, ProductGroup = group2, ProductBrandId = 3 }, new ProductBase { Code = "03031752", Name = "Kõrvarõngad CZ sampanja", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group2.ProductTypeId, ProductGroup = group2, ProductBrandId = 3 }, new ProductBase { Code = "03031528", Name = "Kõrvarõngad CZ", ProductStatus = status2, ProductMaterial = material1, ProductSourceType = sourceType2, ProductDestinationType = destType1, ProductTypeId = group2.ProductTypeId, ProductGroup = group2, ProductBrandId = 3 }, new ProductBase { Code = "03090239", Name = "Ripats CZ sinine", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType2, ProductDestinationType = destType2, ProductTypeId = group3.ProductTypeId, ProductGroup = group3, ProductBrandId = 3 }, new ProductBase { Code = "03090662", Name = "Ripats sünt. aleksandriit", ProductStatus = status2, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group3.ProductTypeId, ProductGroup = group3, ProductBrandId = 1, ProductCollectionId = 1 }, new ProductBase { Code = "03090797", Name = "Ripats CZ valge", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group3.ProductTypeId, ProductGroup = group3, ProductBrandId = 3 }, new ProductBase { Code = "03090820", Name = "Ripats CZ valge", ProductStatus = status2, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group3.ProductTypeId, ProductGroup = group3, ProductBrandId = 3 }, new ProductBase { Code = "03092347", Name = "Ripats CZ lavender", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType2, ProductDestinationType = destType2, ProductTypeId = group3.ProductTypeId, ProductGroup = group3, ProductBrandId = 3 }, new ProductBase { Code = "03092477", Name = "Ripats CZ", ProductStatus = status2, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group3.ProductTypeId, ProductGroup = group3, ProductBrandId = 3 }, new ProductBase { Code = "03098704", Name = "Ripats Hobuseraud CZ", ProductStatus = status1, ProductMaterial = material1, ProductSourceType = sourceType1, ProductDestinationType = destType1, ProductTypeId = group3.ProductTypeId, ProductGroup = group3, ProductBrandId = 3 } }; context.AddRange(productBases); context.SaveChanges(); // products var products = new List <Product>(); foreach (var pb in productBases) { if (pb.ProductVariantTypeId is null) { products.Add(new Product { Code = pb.Code, Name = pb.Name, ProductBaseId = pb.Id }); } else { foreach (var pv in variants) { if (random.Next(0, 3) == 0) { continue; } products.Add(new Product { Code = $"{pb.Code}-{pv.Code}", Name = $"{pb.Name} {pv.Name}", ProductBaseId = pb.Id, ProductVariantId = pv.Id }); } } } context.AddRange(products); context.SaveChanges(); #endregion #region prices module // 5 price lists var priceLists = new PriceList[] { new PriceList { Name = "Eesti", CurrencyCode = "EUR" }, new PriceList { Name = "Eksport", CurrencyCode = "EUR" }, new PriceList { Name = "Soome", CurrencyCode = "EUR" }, new PriceList { Name = "Gense", CurrencyCode = "SEK" }, new PriceList { Name = "Juveel Sverige", CurrencyCode = "SEK" }, }; context.AddRange(priceLists); context.SaveChanges(); // prices var prices = new List <Price>(); foreach (var priceList in priceLists) { foreach (var product in products) { if (priceList.CurrencyCode == "EUR" || (priceList.CurrencyCode == "SEK" && random.Next(1, 10) < 6)) { prices.Add(new Price { ProductId = product.Id, PriceListId = priceList.Id, UnitPrice = priceList.CurrencyCode == "EUR" ? random.Next(100, 400) : random.Next(1000, 5000) }); } } } context.AddRange(prices); context.SaveChanges(); #endregion #region locations and inventory module // location types var locationTypes = new LocationType[] { new LocationType { Code = "VL", Name = "Valmiskaubaladu" }, new LocationType { Code = "KL", Name = "Komisjoniladu" }, new LocationType { Code = "PL", Name = "Poeladu" } }; context.AddRange(locationTypes); context.SaveChanges(); // 12 locations var locations = new Location[] { new Location { LocationTypeId = 1, Code = "VL-EST", Name = "Eesti" }, new Location { LocationTypeId = 1, Code = "VL-EKSP", Name = "Eksport" }, new Location { LocationTypeId = 1, Code = "VL-NÄIDIS", Name = "Näidiste ladu" }, new Location { LocationTypeId = 1, Code = "VL-KULTAK", Name = "Kultakeskus" }, new Location { LocationTypeId = 1, Code = "VL-GENSE", Name = "Gense" }, new Location { LocationTypeId = 1, Code = "VL-JUVSVE", Name = "Juveel Sverige" }, new Location { LocationTypeId = 2, Code = "KL-LEVI", Name = "Levi Design" }, new Location { LocationTypeId = 2, Code = "KL-INKUB", Name = "Tallinna Ettevõtlusinkubaatorid" }, new Location { LocationTypeId = 3, Code = "PL-JUVÄRI", Name = "Juveeliäri" }, new Location { LocationTypeId = 3, Code = "PL-JÄRVE", Name = "Firmakauplus Järve" }, new Location { LocationTypeId = 3, Code = "PL-ROCCA", Name = "Firmakauplus Rocca al Mare" }, new Location { LocationTypeId = 3, Code = "PL-KRISTI", Name = "Firmakauplus Kristiine" } }; context.AddRange(locations); context.SaveChanges(); // inventory var inventory = new List <Inventory>(); foreach (var location in locations) { var productIds = Enumerable.Range(1, random.Next(1, products.Count + 1)); foreach (int productId in productIds) { int stockQuantity = 0; int reservedQuantity = 0; if (random.Next(1, 10) < 7) { stockQuantity = random.Next(1, 10); if (random.Next(1, 10) < 8) { reservedQuantity = (stockQuantity % 2) == 0 ? random.Next(1, stockQuantity) : 0; } else { reservedQuantity = stockQuantity; } } inventory.Add(new Inventory { LocationId = location.Id, ProductId = productId, StockQuantity = stockQuantity, ReservedQuantity = reservedQuantity }); } } context.AddRange(inventory); context.SaveChanges(); #endregion }
public PriceList savePriceList(PriceList entity) { this._priceEntity.SaveOrUpdate(entity); return entity; }
public decimal FindMaxDiscountPerList(PriceList pl) { return(repository.FindMaxDiscountPerList(pl)); }
public void DeletePrice(PriceList entity) { this._priceEntity.Delete(entity); }
static void Main(string[] args) { PriceList[] pricelist = new PriceList[50]; DateTime[] dateTimes = new DateTime[50]; string[] explainer = new string[50]; int pos = 3; pricelist[0].nameofprod = "Папка"; pricelist[0].type = EnumType.K; pricelist[0].price = 4.75; pricelist[0].quantity = 400; pricelist[1].nameofprod = "Бумага A4 (пачка)"; pricelist[1].type = EnumType.K; pricelist[1].price = 45.90; pricelist[1].quantity = 100; pricelist[2].nameofprod = "Калькулятор"; pricelist[2].type = EnumType.O; pricelist[2].price = 411.00; pricelist[2].quantity = 10; bool mark = true; int datepos = 0; while (mark) { Console.WriteLine("1 - Просмотр таблицы\n2 - Добавить запись\n3 - Удалить запись\n4 - Обновить запись\n5 - Поиск записей\n6 - Просмотреть лог\n7 - Сортировка данных \n8 - Выход"); string inpusolution = Console.ReadLine(); switch (inpusolution) { case "1": Console.Clear(); for (int i = 0; i < pos; i++) { Console.WriteLine($"{pricelist[i].nameofprod,-20}|{pricelist[i].type,-15}|{pricelist[i].price,-10}|{pricelist[i].quantity,-10}"); } Console.ReadKey(); Console.Clear(); break; case "2": Console.Clear(); Console.WriteLine("Введите наименование товара: "); pricelist[pos].nameofprod = Console.ReadLine(); Console.WriteLine("Введите тип товара: "); pricelist[pos].type = (EnumType)Enum.Parse(typeof(EnumType), Console.ReadLine()); bool IsCorrect = Enum.IsDefined(typeof(EnumType), pricelist[pos].type); if (IsCorrect) { Console.WriteLine("Value is correct."); } else { Console.WriteLine("Value is not correct."); } Console.WriteLine("Введите Цена за 1 шт (грн): "); pricelist[pos].price = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Введите количество товара: "); pricelist[pos].quantity = Convert.ToInt32(Console.ReadLine()); dateTimes[datepos] = DateTime.Now; string addnote = pricelist[3].nameofprod; if (IsCorrect == true) { explainer[datepos] = $"запись добавлена \"{addnote}\""; datepos++; pos++; } //else //{ //} Console.Clear(); break; case "3": Console.Clear(); Console.WriteLine("Введите номер удаляемой записи: "); int numdel = Convert.ToInt32(Console.ReadLine()); string numrec = pricelist[numdel].nameofprod; explainer[datepos] = $"запись удалена \"{numrec}\""; for (int i = numdel; i < pos; i++) { pricelist[i].nameofprod = pricelist[i + 1].nameofprod; pricelist[i].type = pricelist[i + 1].type; pricelist[i].price = pricelist[i + 1].price; pricelist[i].quantity = pricelist[i + 1].quantity; } pos--; dateTimes[datepos] = DateTime.Now; datepos++; Console.Clear(); break; case "4": Console.Clear(); Console.WriteLine("Введите номер редактируемой записи: "); int numberred = Convert.ToInt32(Console.ReadLine()); string postupdated = pricelist[numberred].nameofprod; Console.WriteLine("Введите новое наименование товара: "); pricelist[numberred].nameofprod = Console.ReadLine(); Console.WriteLine("Введите новый тип товара: "); pricelist[numberred].type = (EnumType)Enum.Parse(typeof(EnumType), Console.ReadLine()); bool IsCorrect1 = Enum.IsDefined(typeof(EnumType), pricelist[pos].type); if (IsCorrect1) { Console.WriteLine("Value is correct."); } else { Console.WriteLine("Value is not correct."); } Console.WriteLine("Введите новую Цену за 1 шт (грн):"); pricelist[numberred].price = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Введите новое количество товара: "); pricelist[numberred].quantity = Convert.ToInt32(Console.ReadLine()); dateTimes[datepos] = DateTime.Now; if (IsCorrect1 == false) { explainer[datepos] = $"запись обновлена \"{postupdated}\""; datepos++; } Console.Clear(); break; case "5": Console.Clear(); Console.WriteLine("Введите минимальную цену: "); double minprice = Convert.ToDouble(Console.ReadLine()); for (int i = 0; i < pos; i++) { if (pricelist[i].price > minprice) { Console.WriteLine($"{pricelist[i].nameofprod,-20}|{pricelist[i].type,-15}|{pricelist[i].price,-10}|{pricelist[i].quantity,-10}"); } } Console.ReadLine(); Console.Clear(); break; case "6": Console.Clear(); TimeSpan longperiodinactivity = dateTimes[1].Subtract(dateTimes[0]); for (int i = 0; i < datepos; i++) { Console.WriteLine($"{dateTimes[i].Hour}:{dateTimes[i].Minute}:{dateTimes[i].Second} - {explainer[i]}"); if ((dateTimes[i + 1].Subtract(dateTimes[i])) > longperiodinactivity) { longperiodinactivity = dateTimes[i + 1].Subtract(dateTimes[i]); } } Console.WriteLine(); Console.WriteLine($"{longperiodinactivity.Hours}:{longperiodinactivity.Minutes}:{longperiodinactivity.Seconds} - Наибольший период бездействия пользователя."); Console.ReadLine(); Console.Clear(); break; case "7": SortData(pricelist, pos); Console.Clear(); Console.WriteLine("Сортировка успешно произведена!"); Console.ReadKey(); Console.Clear(); break; case "8": mark = false; break; default: Console.Clear(); break;
public PriceListDetail GetLastestPriceListDetail(PriceList priceList, Item item, DateTime effectiveDate, Currency currency, Uom uom) { return GetLastestPriceListDetail(priceList.Code, item.Code, effectiveDate, currency.Code, uom.Code); }
/// <summary> /// 获取商品的当前价格 /// </summary> private PriceList GetPriceList() { //先忽略平台和skuId,稍后从结果集中过滤 var caller = this._realTime ? (Func<int, string, int, PriceList>)GetPriceFromService : GetPriceFromCache; var list = caller(this._userId, this._equipmentCode, this._goodsId); var result = new PriceList(this._goodsId); foreach (var price in (list ?? result)) { if (this._platType != Enum_PlatType.ALL && !price.ContainsPlatType(this._platType)) { continue; } if (this._skuId != 0 && price.SkuId != this._skuId) { continue; } result.Add(price); } return result; }
public string PostPriceListLine(PriceListLine priceListLine) { if (!ModelState.IsValid) { return("bad"); } if (priceListLine == null) { return("null"); } PriceList priceListExist = db.PriceLists.GetAll().FirstOrDefault(u => u.IdPriceList == priceListLine.IDPriceList); TicketType id = Enums.TicketType.Hourly; if (priceListLine.TypeOfTicket == "One-hour") { id = Enums.TicketType.Hourly; } else if (priceListLine.TypeOfTicket == "Day") { id = Enums.TicketType.Daily; } else if (priceListLine.TypeOfTicket == "Mounth") { id = Enums.TicketType.Monthly; } else if (priceListLine.TypeOfTicket == "Year") { id = Enums.TicketType.Annual; } Price priceExist = db.Prices.GetAll().FirstOrDefault(u => (u.IdPrice == priceListLine.IDPrice)); Price newPrice = new Price(); if (priceExist == null) { newPrice.Pricelists = new List <PriceList>(); newPrice.Value = priceListLine.Value; newPrice.Type = id; } if (priceListExist == null) { PriceList newPriceList = new PriceList() { StartDate = priceListLine.ValidFrom, EndDate = priceListLine.ValidFrom, Prices = new List <Price>() }; newPriceList.Prices = new List <Price>(); if (priceExist == null) { try { newPriceList.Prices.Add(newPrice); db.PriceLists.Add(newPriceList); newPrice.Pricelists.Add(newPriceList); db.Prices.Add(newPrice); db.Complete(); } catch (Exception e) { Console.WriteLine(e.Message); } } else { priceExist.Value = priceListLine.Value; newPriceList.Prices.Add(priceExist); db.PriceLists.Add(newPriceList); priceExist.Pricelists.Add(newPriceList); db.Prices.Update(priceExist); } } else { if (priceListExist.Prices != null) { foreach (Price p in priceListExist.Prices) { if (p.Type == id) { return("type of ticket for this price list exists!"); } } } if (priceExist == null) { priceListExist.Prices = new List <Price>(); priceListExist.Prices.Add(newPrice); db.PriceLists.Update(priceListExist); newPrice.Pricelists.Add(priceListExist); db.Prices.Add(newPrice); } else { if (priceListExist.Prices == null) { priceListExist.Prices = new List <Price>(); } if (priceExist.Pricelists == null) { priceExist.Pricelists = new List <PriceList>(); } priceExist.Value = priceListLine.Value; newPrice = priceExist; db.PriceLists.Remove(priceListExist); db.Prices.Remove(priceExist); newPrice.Pricelists.Remove(priceListExist); priceListExist.Prices.Remove(priceExist); priceListExist.Prices.Add(newPrice); newPrice.Pricelists.Add(priceListExist); db.PriceLists.Add(priceListExist); db.Prices.Add(newPrice); } } try { db.Complete(); } catch (Exception e) { Console.WriteLine(e.Message); } return("ok"); }
protected override void Seed(Kundbolaget.EntityFramework.Context.StoreContext context) { var customers = new Customer[] { new Customer { Id = 1, Name = "Coop", CorporateStucture = "Koncern", CreditLimit = -1, DaysToDelievery = 3, CustomerAuditCode = 1, OrganisationNumber = "555555-5455", CustomerGroupId = 1 }, new Customer { Id = 2, Name = "ICA", CorporateStucture = "Koncern", CreditLimit = -1, DaysToDelievery = 3, CustomerAuditCode = 1, OrganisationNumber = "345555-7645", CustomerGroupId = 1 }, new Customer { Id = 3, Name = "No License Company", CorporateStucture = "", CreditLimit = 1000, DaysToDelievery = 1, CustomerAuditCode = 1, OrganisationNumber = "309545-2345", CustomerGroupId = 1 }, new Customer { Id = 4, Name = "Low credit Company", CorporateStucture = "", CreditLimit = 100, DaysToDelievery = 1, CustomerAuditCode = 1, OrganisationNumber = "308775-2675", CustomerGroupId = 1 } }; var addresses = new Address[] { new Address { Id = 1, StreetName = "Kungsgatan", Number = 1, PostalCode = "11232", Area = "Stockholm", Country = "Sweden" }, new Address { Id = 2, StreetName = "Kungsgatan", Number = 2, PostalCode = "11232", Area = "Stockholm", Country = "Sweden" }, new Address { Id = 3, StreetName = "Kungsgatan", Number = 3, PostalCode = "11232", Area = "Stockholm", Country = "Sweden" }, new Address { Id = 4, StreetName = "Bergsgatan", Number = 77, PostalCode = "11632", Area = "Stockholm", Country = "Sweden" }, new Address { Id = 5, StreetName = "Licensgatan", Number = 101, PostalCode = "13452", Area = "Stockholm", Country = "Sweden" }, new Address { Id = 6, StreetName = "Kreditgatan", Number = 202, PostalCode = "10982", Area = "Stockholm", Country = "Sweden" } }; var products = new Product[] { new Product { Id = 1, Name = "Pripps blå", Alcohol = 3.5f, AuditCode = 1, ConsumerPackage = ConsumerPackage.Flaska, ConsumerPerStorage = 12, ProductGroup = ProductGroup.Öl, StoragePackage = StoragePackage.Back, VatCode = 1, Volume = 33 }, new Product { Id = 2, Name = "IPA", Alcohol = 4f, AuditCode = 1, ConsumerPackage = ConsumerPackage.Flaska, ConsumerPerStorage = 12, ProductGroup = ProductGroup.Öl, StoragePackage = StoragePackage.Back, VatCode = 1, Volume = 33 }, new Product { Id = 3, Name = "Strongbow", Alcohol = 4.5f, AuditCode = 1, ConsumerPackage = ConsumerPackage.Flaska, ConsumerPerStorage = 12, ProductGroup = ProductGroup.Cider, StoragePackage = StoragePackage.Back, VatCode = 1, Volume = 50 }, new Product { Id = 4, Name = "Bishops finger", Alcohol = 5.5f, AuditCode = 1, ConsumerPackage = ConsumerPackage.Flaska, ConsumerPerStorage = 12, ProductGroup = ProductGroup.Öl, StoragePackage = StoragePackage.Back, VatCode = 1, Volume = 50 }, new Product { Id = 5, Name = "Chapel Hill", Alcohol = 12f, AuditCode = 1, ConsumerPackage = ConsumerPackage.Flaska, ConsumerPerStorage = 12, ProductGroup = ProductGroup.Mousserande, StoragePackage = StoragePackage.Back, VatCode = 1, Volume = 75 }, new Product { Id = 6, Name = "Koskenkorva", Alcohol = 40f, AuditCode = 1, ConsumerPackage = ConsumerPackage.Flaska, ConsumerPerStorage = 12, ProductGroup = ProductGroup.Starksprit, StoragePackage = StoragePackage.Kartong, VatCode = 1, Volume = 100 }, new Product { Id = 7, Name = "Eriksberg Hovmästarlager", Alcohol = .5f, AuditCode = 1, ConsumerPackage = ConsumerPackage.Flaska, ConsumerPerStorage = 24, ProductGroup = ProductGroup.Alkoholfritt, StoragePackage = StoragePackage.Back, VatCode = 1, Volume = 33 }, new Product { Id = 8, Name = "Dom Perignon", Alcohol = 12.5f, AuditCode = 1, ConsumerPackage = ConsumerPackage.Flaska, ConsumerPerStorage = 4, ProductGroup = ProductGroup.Mousserande, StoragePackage = StoragePackage.Kartong, VatCode = 1, Volume = 75, ProductStatus = ProductStatus.Beställningsvara } }; var warehouses = new Warehouse[] { new Warehouse { Id = 1, Name = "Centrallagret", City = "Stockholm", Country = "Sweden", ZipCode = 11111 } }; var storagePlaces = Enumerable.Range(0, 1452).Select(x => new StoragePlace { Id = x, WarehouseId = 1 }).ToArray(); storagePlaces[1].ArrivalDate = DateTime.Today; storagePlaces[1].ProductId = products[0].Id; storagePlaces[1].TotalAmount = 30; storagePlaces[1].Vacant = false; storagePlaces[2].ArrivalDate = DateTime.Today; storagePlaces[2].ProductId = products[0].Id; storagePlaces[2].TotalAmount = 30; storagePlaces[2].Vacant = false; storagePlaces[3].ArrivalDate = DateTime.Today; storagePlaces[3].ProductId = products[0].Id; storagePlaces[3].TotalAmount = 20; storagePlaces[3].Vacant = false; storagePlaces[4].ArrivalDate = DateTime.Today; storagePlaces[4].ProductId = products[0].Id; storagePlaces[4].TotalAmount = 20; storagePlaces[4].Vacant = false; storagePlaces[5].ArrivalDate = DateTime.Today; storagePlaces[5].ProductId = products[1].Id; storagePlaces[5].TotalAmount = 100; storagePlaces[5].Vacant = false; storagePlaces[6].ArrivalDate = DateTime.Today; storagePlaces[6].ProductId = products[1].Id; storagePlaces[6].TotalAmount = 100; storagePlaces[6].Vacant = false; storagePlaces[7].ArrivalDate = DateTime.Today; storagePlaces[7].ProductId = products[1].Id; storagePlaces[7].TotalAmount = 100; storagePlaces[7].Vacant = false; storagePlaces[8].ArrivalDate = DateTime.Today; storagePlaces[8].ProductId = products[2].Id; storagePlaces[8].TotalAmount = 300; storagePlaces[8].Vacant = false; storagePlaces[9].ArrivalDate = DateTime.Today; storagePlaces[9].ProductId = products[3].Id; storagePlaces[9].TotalAmount = 300; storagePlaces[9].Vacant = false; storagePlaces[10].ArrivalDate = DateTime.Today; storagePlaces[10].ProductId = products[4].Id; storagePlaces[10].TotalAmount = 200; storagePlaces[10].Vacant = false; storagePlaces[11].ArrivalDate = DateTime.Today; storagePlaces[11].ProductId = products[5].Id; storagePlaces[11].TotalAmount = 100; storagePlaces[11].Vacant = false; storagePlaces[12].ArrivalDate = DateTime.Today; storagePlaces[12].ProductId = products[5].Id; storagePlaces[12].TotalAmount = 100; storagePlaces[12].Vacant = false; storagePlaces[13].ArrivalDate = DateTime.Today; storagePlaces[13].ProductId = products[6].Id; storagePlaces[13].TotalAmount = 600; storagePlaces[13].Vacant = false; var customergroup = new CustomerGroup[] { new CustomerGroup { Id = 1, Name = "Livsmedelbutik" }, new CustomerGroup { Id = 2, Name = "Högskola" }, new CustomerGroup { Id = 3, Name = "Restaurang" }, }; var ca = new CustomerAddress[] { new CustomerAddress { Id = 1, CustomerId = 1, AddressId = 1, AddressType = AddressType.Leverans }, new CustomerAddress { Id = 2, CustomerId = 1, AddressId = 2, AddressType = AddressType.Leverans }, new CustomerAddress { Id = 3, CustomerId = 1, AddressId = 3, AddressType = AddressType.Faktura }, new CustomerAddress { Id = 4, CustomerId = 1, AddressId = 3, AddressType = AddressType.Besök }, new CustomerAddress { Id = 5, CustomerId = 2, AddressId = 4, AddressType = AddressType.Leverans }, new CustomerAddress { Id = 6, CustomerId = 2, AddressId = 4, AddressType = AddressType.Faktura }, new CustomerAddress { Id = 7, CustomerId = 3, AddressId = 5, AddressType = AddressType.Leverans }, new CustomerAddress { Id = 8, CustomerId = 3, AddressId = 5, AddressType = AddressType.Faktura }, new CustomerAddress { Id = 9, CustomerId = 4, AddressId = 6, AddressType = AddressType.Leverans }, new CustomerAddress { Id = 10, CustomerId = 4, AddressId = 6, AddressType = AddressType.Faktura }, }; var priceLists = new PriceList[] { new PriceList { Id = 1, CustomerGroupId = 1, ProductId = 1, Price = 20, RebatePerPallet = 2, StartDate = DateTime.Parse("01/01/2017") }, new PriceList { Id = 2, CustomerGroupId = 1, ProductId = 2, Price = 20, RebatePerPallet = 3, StartDate = DateTime.Parse("01/01/2017") }, new PriceList { Id = 3, CustomerGroupId = 1, ProductId = 3, Price = 20, RebatePerPallet = 4, StartDate = DateTime.Parse("01/01/2017") }, new PriceList { Id = 4, CustomerGroupId = 1, ProductId = 4, Price = 20, RebatePerPallet = 5, StartDate = DateTime.Parse("01/01/2017") }, new PriceList { Id = 5, CustomerGroupId = 1, ProductId = 5, Price = 68, RebatePerPallet = 3, StartDate = DateTime.Parse("01/01/2017") }, new PriceList { Id = 6, CustomerGroupId = 1, ProductId = 7, Price = 11.90f, RebatePerPallet = 2, StartDate = DateTime.Parse("01/01/2017") }, }; var licenses = new AlcoholLicense[] { new AlcoholLicense { Id = 1, CustomerId = 1, StartDate = DateTime.Parse("2016-01-01"), EndDate = DateTime.Parse("2016-12-31") }, new AlcoholLicense { Id = 2, CustomerId = 1, StartDate = DateTime.Parse("2017-01-01"), EndDate = DateTime.Parse("2017-12-31") }, new AlcoholLicense { Id = 3, CustomerId = 2, StartDate = DateTime.Parse("2017-01-01"), EndDate = DateTime.Parse("2017-12-31") }, }; context.Warehouses.AddOrUpdate(warehouses); context.Customers.AddOrUpdate(customers); context.StoragePlaces.AddOrUpdate(x => x.Id, storagePlaces); context.Addresses.AddOrUpdate(addresses); context.Products.AddOrUpdate(products); context.CustomerAddresses.AddOrUpdate(ca); context.CustomerGroups.AddOrUpdate(customergroup); context.PriceLists.AddOrUpdate(priceLists); context.AlcoholLicense.AddOrUpdate(licenses); }
public string EditPriceListLine(PriceListLine priceListLine) { if (!ModelState.IsValid) { return("bad"); } if (priceListLine == null) { return("null"); } TicketType type = Enums.TicketType.Hourly; if (priceListLine.TypeOfTicket == "One-hour") { type = Enums.TicketType.Hourly; } else if (priceListLine.TypeOfTicket == "Day") { type = Enums.TicketType.Daily; } else if (priceListLine.TypeOfTicket == "Mounth") { type = Enums.TicketType.Monthly; } else if (priceListLine.TypeOfTicket == "Year") { type = Enums.TicketType.Annual; } PriceList priceListExist = db.PriceLists.GetAll().FirstOrDefault(u => u.IdPriceList == priceListLine.IDPriceList); TicketType id = db.Prices.GetAll().FirstOrDefault(u => u.Type == type).Type; Price priceExist = db.Prices.GetAll().FirstOrDefault(u => (u.IdPrice == priceListLine.IDPrice)); Price newPrice = new Price(); PriceList priceList = new PriceList() { StartDate = priceListLine.ValidFrom, EndDate = priceListLine.ValidFrom, Prices = new List <Price>() }; newPrice.Pricelists = new List <PriceList>(); newPrice.Value = priceListLine.Value; newPrice.Type = db.Prices.GetAll().FirstOrDefault(u => u.Type == type).Type; priceList.Prices.Add(newPrice); Price priceFromBase = db.Prices.GetAll().FirstOrDefault(u => u.IdPrice == priceListLine.IDPrice); if (priceExist != null) { db.Prices.Remove(priceExist); } db.Prices.Add(newPrice); if (priceListExist != null) { db.PriceLists.Remove(priceListExist); } db.PriceLists.Add(priceList); try { db.Complete(); } catch (Exception e) { Console.WriteLine(e.Message); } return("ok"); }
public virtual void CreatePriceList(PriceList entity) { Create(entity); }
/// <summary> /// POST api/PriceListItems /// Insert new price item into the price list. /// </summary> public PriceList Create(PriceList model) { return(Post <PriceList, PriceList>(ResourceUrl, model)); }
public virtual void DeletePriceList(PriceList entity) { Delete(entity); }
/// <summary> /// PUT api/PriceListItems/{id} /// Method updates price list item. /// </summary> public PriceList Update(int priceListItemId, PriceList model) { return(Put <PriceList, PriceList>(ResourceUrl + "/" + priceListItemId, model)); }
public ActionResult <IEnumerable <ProductListItem> > Search(string ProductCodes, string Description, Families?Family, string Style, int?Level, string SupplierCode, string ClassCode, bool?IsActive = true) { if (string.IsNullOrWhiteSpace(ProductCodes) && string.IsNullOrWhiteSpace(Description) && !Family.HasValue && string.IsNullOrWhiteSpace(Style) && string.IsNullOrWhiteSpace(SupplierCode) && string.IsNullOrWhiteSpace(ClassCode)) { throw new Exception("At least one parameter is needed to call this api"); } var qryProducts = from P in DBContext.PD_S_PRODUCT /* * join PE in DBContext.PD_S_PRODUCT_EXT_AUS on P.PRODUCT_CODE equals PE.PRODUCT_CODE into Ext * join PC in DBContext.PD_S_CLASS on P.CLASS_CODE equals PC.CLASS_CODE into Class * join PSC in DBContext.PD_S_SUBCLASS on new { P.COMPANY_CODE, P.DIVISION_CODE, P.CLASS_CODE, P.SUBCLASS_CODE } equals new { PSC.COMPANY_CODE, PSC.DIVISION_CODE, PSC.CLASS_CODE, PSC.SUBCLASS_CODE } into SubClass * join PG in DBContext.PD_S_GROUP on P.GROUP_CODE equals PG.GROUP_CODE into Group * join PW in DBContext.PD_S_PRODUCT_WARRANTIES_EXT_AUS on P.PRODUCT_CODE equals PW.PRODUCT_CODE into Warranty * join PL in DBContext.PD_S_PRODUCT_PRICELIST on P.PRODUCT_CODE equals PL.PRODUCT_CODE into PriceList * join PB in DBContext.PD_S_BAND on P.BAND_CODE equals PB.BAND_CODE into Band * join PS in DBContext.PD_S_SUPPLIER on P.SUPPLIER_CODE equals PS.SUPPLIER_CODE into Supplier */ join PE in DBContext.PD_S_PRODUCT_EXT_AUS on new { P.COMPANY_CODE, P.DIVISION_CODE, P.PRODUCT_CODE } equals new { PE.COMPANY_CODE, PE.DIVISION_CODE, PE.PRODUCT_CODE } into Ext join PC in DBContext.PD_S_CLASS on new { P.COMPANY_CODE, P.DIVISION_CODE, P.CLASS_CODE } equals new { PC.COMPANY_CODE, PC.DIVISION_CODE, PC.CLASS_CODE } into Class join PSC in DBContext.PD_S_SUBCLASS on new { P.COMPANY_CODE, P.DIVISION_CODE, P.CLASS_CODE, P.SUBCLASS_CODE } equals new { PSC.COMPANY_CODE, PSC.DIVISION_CODE, PSC.CLASS_CODE, PSC.SUBCLASS_CODE } into SubClass join PG in DBContext.PD_S_GROUP on new { P.COMPANY_CODE, P.DIVISION_CODE, P.GROUP_CODE } equals new { PG.COMPANY_CODE, PG.DIVISION_CODE, PG.GROUP_CODE } into Group join PW in DBContext.PD_S_PRODUCT_WARRANTIES_EXT_AUS on new { P.COMPANY_CODE, P.DIVISION_CODE, P.PRODUCT_CODE } equals new { PW.COMPANY_CODE, PW.DIVISION_CODE, PW.PRODUCT_CODE } into Warranty join PL in DBContext.PD_S_PRODUCT_PRICELIST on new { P.COMPANY_CODE, P.DIVISION_CODE, P.PRODUCT_CODE } equals new { PL.COMPANY_CODE, PL.DIVISION_CODE, PL.PRODUCT_CODE } into PriceList join PB in DBContext.PD_S_BAND on new { P.COMPANY_CODE, P.DIVISION_CODE, P.BAND_CODE } equals new { PB.COMPANY_CODE, PB.DIVISION_CODE, PB.BAND_CODE } into Band join PS in DBContext.PD_S_SUPPLIER on new { P.COMPANY_CODE, P.DIVISION_CODE, P.SUPPLIER_CODE } equals new { PS.COMPANY_CODE, PS.DIVISION_CODE, PS.SUPPLIER_CODE } into Supplier select new ProductDBInfo { Product = P, ProductExt = Ext.SingleOrDefault(), ProductClass = Class.Where(E => E.DT_START.GetValueOrDefault(DateTime.MinValue) <= DateTime.Today && E.DT_END.GetValueOrDefault(DateTime.MaxValue) <= DateTime.Today).FirstOrDefault(), ProductSubClass = SubClass.Where(E => E.DT_START.GetValueOrDefault(DateTime.MinValue) <= DateTime.Today && E.DT_END.GetValueOrDefault(DateTime.MaxValue) <= DateTime.Today).FirstOrDefault(), ProductGroup = Group.Where(E => E.DT_START.GetValueOrDefault(DateTime.MinValue) <= DateTime.Today && E.DT_END.GetValueOrDefault(DateTime.MaxValue) <= DateTime.Today).FirstOrDefault(), ProductBand = Band.Where(E => E.DT_START.GetValueOrDefault(DateTime.MinValue) <= DateTime.Today && E.DT_END.GetValueOrDefault(DateTime.MaxValue) <= DateTime.Today).FirstOrDefault(), ProductWarranty = Warranty.OrderByDescending(E => E.DT_EFFECTIVE_FROM).FirstOrDefault(E => E.DT_EFFECTIVE_FROM <= DateTime.Today), ProductSupplier = Supplier.Where(E => E.DT_START.GetValueOrDefault(DateTime.MinValue) <= DateTime.Today && E.DT_END.GetValueOrDefault(DateTime.MaxValue) <= DateTime.Today).FirstOrDefault(), ProductPriceList = PriceList.Where(E => E.DT_VALID <= DateTime.Today).OrderByDescending(E => E.DT_VALID) }; var predicate = PredicateBuilder.New <ProductDBInfo>(true); if (!string.IsNullOrWhiteSpace(ProductCodes)) { string[] ProductList = ProductCodes.Split("|", StringSplitOptions.RemoveEmptyEntries); if (ProductList.Length > 0) { predicate = predicate.And(E => ProductList.Contains(E.Product.PRODUCT_CODE)); } } if (!string.IsNullOrWhiteSpace(Description)) { predicate = predicate.And(E => E.Product.PRODUCT_DESCR.Contains(Description)); } if (Level.HasValue) { predicate = predicate.And(E => E.Product.BAND_CODE == Level.Value.ToString()); } if (!string.IsNullOrWhiteSpace(Style)) { predicate = predicate.And(E => E.Product.SUBCLASS_CODE == Style); } if (Family.HasValue) { string PEDescription = Family.Value.GetDescription(); predicate = predicate.And(E => E.ProductExt != null && E.ProductExt.PRODUCT_COMMER != null && E.ProductExt.PRODUCT_COMMER.StartsWith(PEDescription)); } if (!string.IsNullOrWhiteSpace(SupplierCode)) { string[] SupplierList = SupplierCode.Split("|", StringSplitOptions.RemoveEmptyEntries); if (SupplierList.Length > 0) { predicate = predicate.And(E => SupplierList.Contains(E.Product.SUPPLIER_CODE)); } } if (!string.IsNullOrWhiteSpace(ClassCode)) { predicate = predicate.And(E => E.Product.CLASS_CODE == ClassCode); } List <ProductListItem> Result = new List <ProductListItem>(); foreach (ProductDBInfo Item in qryProducts.Where(predicate).Take(Settings.Value.MaxQueryResult)) { ProductListItem ResultItem = new ProductListItem(Item); Result.Add(ResultItem); } return(Result); }
public async Task <int> CreatePriceList(PriceList priceList) { var result = await this.httpService.Post <PriceList>("/priceLists", priceList); return(result.Id); }
//public WorkListItemHistory SaveAudit(WorkListItem workListItem, HistoryStatus historyStatus) //{ // WorkListItemHistory workListItemHistory = new WorkListItemHistory(); // workListItemHistory.Price = workListItem.Price; // workListItemHistory.LastApproved = workListItem.LastApproved; // workListItemHistory.LastPublishItem = workListItem.LastPublishItem; // workListItemHistory.PriceCurrency = workListItem.PriceCurrency; // workListItemHistory.PriceList = workListItem.PriceList; // workListItemHistory.WorkListItemStatus = workListItem.WorkListItemStatus; // workListItemHistory.PriceBase = workListItem.PriceAttribute.PriceBase; // workListItemHistory.CurrencyRate = workListItem.CurrencyRate; // workListItemHistory.HistoryStatus = historyStatus; // workListItemHistory.PricePurchaseCurrencyRate = workListItem.PricePurchaseCurrencyRate; // workListItemHistory.PriceSuggestCurrencyRate = workListItem.PriceSuggestCurrencyRate; // Save(workListItemHistory); // return workListItemHistory; //} //public void SaveAudit(IList<WorkListItem> wliList, HistoryStatus historyStatus) //{ // foreach (WorkListItem workListItem in wliList) // { // SaveAudit(workListItem, historyStatus); // } //} public IList <WorkListItemHistory> GetByProduct(Product product, PriceList priceList, GridState gridState, out int totalRecords) { ICriteria crit = GetByProductCriteria(product, priceList); int pageNumber = gridState.PageNumber; int pageSize = gridState.PageSize; crit.AddOrder(new Order("PriceList", true)); crit.AddOrder(new Order("TimeStamp.CreatedOn", false)); string[] sort = gridState.SortField.Split('.'); ICriteria critSort = crit; string sortField = gridState.SortField; if (!sortField.Contains("TimeStamp") && sort.Length > 1) { critSort = crit.CreateCriteria(sort[0]); sortField = sort[1]; } critSort.AddOrder(new Order(sortField, gridState.SortAscending)); IList <WorkListItemHistory> workListItemHistoryList = crit.List <WorkListItemHistory>(); IList <WorkListItemHistory> productListViewList = new List <WorkListItemHistory>(); totalRecords = workListItemHistoryList.Count; pageNumber = Utils.AdjustPageNumber(pageNumber, pageSize, totalRecords); int count; int maxcount; if (pageNumber == 1) { count = 0; } else { count = (pageNumber - 1) * gridState.PageSize; } maxcount = count + pageSize; decimal price = -1; foreach (WorkListItemHistory wlih in workListItemHistoryList) { if (count < maxcount) { if (price == wlih.Price) { continue; } productListViewList.Add(wlih); count++; price = wlih.Price; } else { break; } } return(productListViewList); }
public async Task <int> UpdatePriceList(PriceList priceList) { var result = await this.httpService.Put <PriceList>($"/priceLists/{priceList.Id}", priceList); return(result.Id); }
public static List <Product> QueryProductsByPriceLists(HttpClient httpClient, List <PriceList> priceLists) { var products = new List <Product>(); var fetchXml = string.Empty; fetchXml += "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"; fetchXml += " <entity name='product'>"; fetchXml += " <attribute name='name' />"; fetchXml += " <attribute name='productid' />"; fetchXml += " <attribute name='productnumber' />"; fetchXml += " <attribute name='description' />"; fetchXml += " <attribute name='statecode' />"; fetchXml += " <attribute name='productstructure' />"; fetchXml += " <attribute name='parentproductid' />"; fetchXml += " <attribute name='pricelevelid' />"; fetchXml += " <attribute name='blu_stratareport' />"; fetchXml += " <filter type='and'>"; if (priceLists != null && priceLists.Count > 0) { fetchXml += " <condition attribute='pricelevelid' operator='in'>"; foreach (var priceList in priceLists) { fetchXml += " <value>" + priceList.Id + "</value>"; } fetchXml += " </condition>"; } fetchXml += " <condition attribute='statecode' operator='eq' value='0' />"; fetchXml += " <condition attribute='statuscode' operator='eq' value='1' />"; fetchXml += " </filter>"; fetchXml += " </entity>"; fetchXml += "</fetch>"; var encodedQuery = SharedService.UrlEncode(fetchXml); var odataQuery = webApiQueryUrl + "products?fetchXml=" + encodedQuery; var retrieveResponse = httpClient.GetAsync(odataQuery); var jRetrieveResponse = JObject.Parse(retrieveResponse.Result.Content.ReadAsStringAsync().Result); dynamic systemUserObject = JsonConvert.DeserializeObject(jRetrieveResponse.ToString()); if (systemUserObject == null || systemUserObject.value == null) { return(null); } if (systemUserObject.value.Count == 0) { return(null); } foreach (var data in systemUserObject.value) { var priceList = new PriceList() { Id = data["_pricelevelid_value"] == null ? Guid.Empty : Guid.Parse(data["_pricelevelid_value"].ToString()), Name = data["*****@*****.**"] == null ? "" : data["*****@*****.**"].ToString() }; var parentProduct = new Product() { Id = data["_parentproductid_value"] == null ? Guid.Empty : Guid.Parse(data["_parentproductid_value"].ToString()), Name = data["*****@*****.**"] == null ? "" : data["*****@*****.**"].ToString(), IsParentProduct = true }; var product = new Product() { Id = data["productid"] == null ? Guid.Empty : Guid.Parse(data["productid"].ToString()), Name = data["name"] == null ? "" : data["name"].ToString(), StrataReport = data["blu_stratareport"] != null && (bool)data["blu_stratareport"], ParentProductId = parentProduct.Id, ParentProduct = parentProduct, DefaultPriceListId = priceList.Id, DefaultPriceList = priceList }; products.Add(product); } return(products); }
/// <summary> /// Updates a price list /// </summary> /// <param name="priceList">The price list to update</param> /// <returns>The updated price list</returns> public PriceList Update(PriceList priceList) { return(BaseUpdate(priceList, priceList.Code)); }
public virtual void CreatePriceList(PriceList entity) { entityDao.CreatePriceList(entity); }
/// <summary> /// Create a new price list /// </summary> /// <param name="priceList">The price list to create</param> /// <returns>The created price list</returns> public PriceList Create(PriceList priceList) { return(BaseCreate(priceList)); }
public virtual void DeletePriceList(PriceList entity) { entityDao.DeletePriceList(entity); }
public void Add(PriceList data) { _context.Add(data); }
public string Insert(PriceList entity) { return(bll.Insert(entity).ToString()); }
public void Update(PriceList data) { _context.Update(data); }
public override void Analysis(CurrentPrice price) { try { RPrice = Math.Round(Convert.ToDouble(price.price), RoundNum); switch (PriceType) { case "0": CPrice = RPrice; break; case "1": CPrice = Math.Round(price.price3, RoundNum); break; case "2": CPrice = Math.Round(price.price5, RoundNum); break; case "3": CPrice = Math.Round(price.price7, RoundNum); break; default: CPrice = Math.Round(Convert.ToDouble(price.price), RoundNum); break; } if (BPrice == CPrice) { return; } if (HPrice < CPrice) { HPrice = Math.Round(CPrice, RoundNum); } if (LPrice > CPrice) { LPrice = Math.Round(CPrice, RoundNum); } PriceList.Insert(CPrice); if (!IsUse) { return; } // //매수포지션 사용여부 if (!IsBuyed) { if (IsUseBuy) { //터치여부 if (!IsTouchedBasePrice) { if (PointsUtil.IsMatchedUpDownPattern(PriceList, BasePriceUp, BasePriceDown, BasePattern)) { IsTouchedBasePrice = true; onStrategyTradeRuleHandler("터치", $"베이스 가격터치::현재가{CPrice}"); } //if (PointsUtil.IsBreakThrough(BasePattern, BasePrice, PriceList)) //{ // IsTouchedBasePrice = true; // onStrategyTradeRuleHandler("터치", $"베이스 가격터치::현재가{CPrice}"); //} } if (IsTouchedBasePrice && !IsBuyed) { //매도 if (Position == "1") { if (CPrice == BuyPrice) { IsBuyed = true; SellBuy("진입", Position); onStrategyTradeRuleHandler("진입", $"매도진입::현재가{CPrice}"); } } //매수 if (Position == "2") { if (CPrice == BuyPrice) { IsBuyed = true; SellBuy("진입", Position); onStrategyTradeRuleHandler("진입", $"매수진입::현재가{CPrice}"); } } } } } if (IsBuyed && IsUseLosscut && !IsLosscuted && !IsRevenued) { if (Position == "1") { if (RPrice == LosscutPrice) { IsLosscuted = true; SellBuy("청산", "2"); onStrategyTradeRuleHandler("청산", $"매수청산::현재가{CPrice}"); } } //매수 if (Position == "2") { if (RPrice == LosscutPrice) { IsLosscuted = true; SellBuy("청산", "1"); onStrategyTradeRuleHandler("청산", $"매도청산::현재가{CPrice}"); } } } if (IsBuyed && IsUseRevenue && !IsRevenued && !IsLosscuted) { if (Position == "1") { if (RPrice == RevenuePrice) { IsRevenued = true; SellBuy("청산", "2"); onStrategyTradeRuleHandler("청산", $"매수청산::현재가{CPrice}"); } } //매수 if (Position == "2") { if (RPrice == RevenuePrice) { IsRevenued = true; SellBuy("청산", "1"); onStrategyTradeRuleHandler("청산", $"매도청산::현재가{CPrice}"); } } } } catch (Exception ex) { onStrategyTradeRuleHandler("ERROR", ex.Message); } finally { BPrice = CPrice; } }
private ConditionBillViewModel(string contractCode, double price, string pricetype, int num) { _IsEnabled = true; //需要合约号 下单的类型和价格 以及数量 ContractCode = contractCode; VarietyModel vm = null; string[] values = contractCode.Split(' '); if (values.Length != 3) { return; } string varietie = values[1]; if (ContractVariety.Varieties.ContainsKey(varietie)) { vm = ContractVariety.Varieties[varietie]; } if (vm == null) { return; } Increment = vm.tick_size; lend = vm.precision; if (pricetype == "市价") { IsTypePrice = Visibility.Visible; IsPrice = Visibility.Collapsed; Price = 0; typePrice = "M"; } else if (pricetype == "对手价") { Price = 0; typePrice = "R"; IsTypePrice = Visibility.Visible; IsPrice = Visibility.Collapsed; } else { Price = price; typePrice = "L"; IsTypePrice = Visibility.Collapsed; IsPrice = Visibility.Visible; } PriceTypeBill = pricetype; _priceType = pricetype; OrderPrice = price; OrderPrice3 = price; Num = num; //触发的类型 KeyValue kv0 = new KeyValue() { Id = 0, Value = "最新价" }; KeyValue kv1 = new KeyValue() { Id = 1, Value = "买一价" }; KeyValue kv2 = new KeyValue() { Id = 2, Value = "卖一价" }; PriceList.Add(kv0); PriceList.Add(kv1); PriceList.Add(kv2); PriceItem = kv0; KeyValue ttype0 = new KeyValue() { Id = 0, Value = ">=" }; KeyValue ttype1 = new KeyValue() { Id = 1, Value = "<=" }; TrrigerConditionItem = ttype0; TrrigerCondition.Add(ttype0); TrrigerCondition.Add(ttype1); KeyValue kv03 = new KeyValue() { Id = 0, Value = "最新价" }; KeyValue kv13 = new KeyValue() { Id = 1, Value = "买一价" }; KeyValue kv23 = new KeyValue() { Id = 2, Value = "卖一价" }; PriceList3.Add(kv03); PriceList3.Add(kv13); PriceList3.Add(kv23); PriceItem3 = kv03; KeyValue ttype03 = new KeyValue() { Id = 0, Value = ">=" }; KeyValue ttype13 = new KeyValue() { Id = 1, Value = "<=" }; IsFirst = true; TrrigerCondition3.Add(ttype03); TrrigerCondition3.Add(ttype13); TrrigerConditionItem3 = ttype03; }
private ICriteria GetDistributorsCriteria(string name, Country country, PriceList priceList, Lookup paymentTerm, DistributorStatus?status, GridState gridState, Lookup saleCondition, Lookup type, CatalogPage page, IList priceListIds, bool isActive) { ICriteria crit = GetCriteria(); if (priceListIds != null) { int[] intPriceListIds = new int[priceListIds.Count]; for (int i = 0; i < priceListIds.Count; i++) { intPriceListIds[i] = Convert.ToInt32(priceListIds[i]); } ICriteria critDistributor = crit.CreateCriteria("PriceList"); critDistributor.Add(Expression.In("ID", intPriceListIds)); } if (!string.IsNullOrEmpty(name)) { Disjunction d = new Disjunction(); d.Add(Expression.InsensitiveLike("Name", name, MatchMode.Anywhere)); d.Add(Expression.InsensitiveLike("Code", name, MatchMode.Anywhere)); crit.Add(d); } if (country != null) { ICriteria critCountry = crit.CreateCriteria("Country"); critCountry.Add(Expression.Eq("ID", country.ID)); } if (priceList != null) { ICriteria critPriceList = crit.CreateCriteria("PriceList"); critPriceList.Add(Expression.Eq("ID", priceList.ID)); } if (paymentTerm != null) { crit.Add(Expression.Eq("PaymentTerm", paymentTerm)); } if (status != null) { crit.Add(Expression.Eq("DistributorStatus", status)); } else if (isActive == false) { crit.Add(Expression.Eq("DistributorStatus", DistributorStatus.Active)); } if (saleCondition != null) { crit.Add(Expression.Eq("SaleConditions", saleCondition)); } if (type != null) { crit.Add(Expression.Eq("Type", type)); } if (page != null) { crit.CreateCriteria("PriceList").CreateCriteria("CategoryPages").Add(Expression.Eq("ID", page.ID)); } return(crit); }
private ConditionBillViewModel(ConditionBillModelViewModel condtion) { //需要合约号 下单的类型和价格 以及数量 _IsEnabled = false; ContractCode = condtion.ContractCode; VarietyModel vm = null; string[] values = condtion.ContractCode.Split(' '); if (values.Length != 3) { return; } string varietie = values[1]; if (ContractVariety.Varieties.ContainsKey(varietie)) { vm = ContractVariety.Varieties[varietie]; } if (vm == null) { return; } Increment = vm.tick_size; lend = vm.precision; typePrice = condtion.PriceType; if (typePrice == "M") { IsTypePrice = Visibility.Visible; IsPrice = Visibility.Collapsed; Price = 0; PriceTypeBill = "市价"; _priceType = "市价"; } else if (typePrice == "R") { Price = 0; PriceTypeBill = "对手价"; _priceType = "对手价"; IsTypePrice = Visibility.Visible; IsPrice = Visibility.Collapsed; } else { Price = condtion.OrderPrice; typePrice = "L"; IsTypePrice = Visibility.Collapsed; IsPrice = Visibility.Visible; } OrderPrice = condtion.TrrigerPrice; OrderPrice3 = condtion.TrrigerPrice; Num = condtion.OrderVolume; //触发的类型 KeyValue kv0 = new KeyValue() { Id = 0, Value = "最新价" }; KeyValue kv1 = new KeyValue() { Id = 1, Value = "买一价" }; KeyValue kv2 = new KeyValue() { Id = 2, Value = "卖一价" }; PriceList.Add(kv0); PriceList.Add(kv1); PriceList.Add(kv2); PriceItem = kv0; KeyValue ttype0 = new KeyValue() { Id = 0, Value = ">=" }; KeyValue ttype1 = new KeyValue() { Id = 1, Value = "<=" }; TrrigerConditionItem = ttype0; TrrigerCondition.Add(ttype0); TrrigerCondition.Add(ttype1); KeyValue kv03 = new KeyValue() { Id = 0, Value = "最新价" }; KeyValue kv13 = new KeyValue() { Id = 1, Value = "买一价" }; KeyValue kv23 = new KeyValue() { Id = 2, Value = "卖一价" }; PriceList3.Add(kv03); PriceList3.Add(kv13); PriceList3.Add(kv23); PriceItem3 = kv03; KeyValue ttype03 = new KeyValue() { Id = 0, Value = ">=" }; KeyValue ttype13 = new KeyValue() { Id = 1, Value = "<=" }; IsFirst = true; TrrigerCondition3.Add(ttype03); TrrigerCondition3.Add(ttype13); TrrigerConditionItem3 = ttype03; if (condtion.Direction == "B") { IsBuy = true; IsSell = false; } else if (condtion.Direction == "S") { IsBuy = false; IsSell = true; } if (condtion.OpenOffset == (int)OffsetType.OFFSET_OPEN) { IsOpen = true; IsCloseing = false; } else if (condtion.OpenOffset == (int)OffsetType.OFFSET_COVER) { IsCloseing = true; IsOpen = false; } if (condtion.ConditionType == (int)YunConditionType.Y_PRICE) { IsFirst = true; IsSecond = false; IsThird = false; TrrigerConditionItem = TrrigerCondition[condtion.TrrigerCondition]; PriceItem = PriceList[condtion.TrrigerPriceType]; } else if (condtion.ConditionType == (int)YunConditionType.Y_TIME) { IsFirst = false; IsSecond = true; IsThird = false; TrrigerTime = condtion.TrrigerContime; //trriger_contime } else if (condtion.ConditionType == (int)YunConditionType.Y_TIMEPRICE) { IsFirst = false; IsSecond = false; IsThird = true; TrrigerConditionItem = TrrigerCondition3[condtion.TrrigerCondition]; PriceItem3 = PriceList3[condtion.TrrigerPriceType]; TrrigerTime3 = condtion.TrrigerContime; } Upatatecondtion = condtion; }
private static PriceList ExtraFromJson(string json) { var list = new PriceList(12900); var beginTime = DateTime.Parse("2016-01-29 11:17:48"); var endTime = DateTime.Now.AddHours(10); var platTypeFlag = ConvertToPlatTypeFlag(false, true, true, true); list.Add(new Price(100, 13595, platTypeFlag, EnumActivityType.手机专享, 5, beginTime, endTime)); list.Add(new Price(149)); return list; }
/// <summary> /// 编辑的参数 /// </summary> /// <param name="para"></param> public ConditionBillViewModel(object para) { //需要合约号 下单的类型和价格 以及数量 //触发的类型 KeyValue kv0 = new KeyValue() { Id = 0, Value = "最新价" }; KeyValue kv1 = new KeyValue() { Id = 1, Value = "买一价" }; KeyValue kv2 = new KeyValue() { Id = 2, Value = "卖一价" }; PriceList.Add(kv0); PriceList.Add(kv1); PriceList.Add(kv2); KeyValue ttype0 = new KeyValue() { Id = 0, Value = ">=" }; KeyValue ttype1 = new KeyValue() { Id = 1, Value = "<=" }; TrrigerCondition.Add(ttype0); TrrigerCondition.Add(ttype1); KeyValue kv03 = new KeyValue() { Id = 0, Value = "最新价" }; KeyValue kv13 = new KeyValue() { Id = 1, Value = "买一价" }; KeyValue kv23 = new KeyValue() { Id = 2, Value = "卖一价" }; PriceList3.Add(kv03); PriceList3.Add(kv13); PriceList3.Add(kv23); KeyValue ttype03 = new KeyValue() { Id = 0, Value = ">=" }; KeyValue ttype13 = new KeyValue() { Id = 1, Value = "<=" }; TrrigerCondition3.Add(ttype03); TrrigerCondition3.Add(ttype13); }
protected void ODS_PriceList_Inserting(object sender, ObjectDataSourceMethodEventArgs e) { Controls_TextBox tbParty = ((Controls_TextBox)(this.FV_PriceList.FindControl("tbParty"))); CheckBox cbIsIncludeTax = ((CheckBox)(this.FV_PriceList.FindControl("cbIsIncludeTax"))); priceList = (PriceList)e.InputParameters[0]; priceList.Code = priceList.Code.Trim(); priceList.IsIncludeTax = cbIsIncludeTax.Checked; if (this.PriceListType == BusinessConstants.CODE_MASTER_PRICE_LIST_TYPE_VALUE_PURCHASE) { priceList.Party = TheSupplierMgr.LoadSupplier(tbParty.Text.Trim()); } else if (this.PriceListType == BusinessConstants.CODE_MASTER_PRICE_LIST_TYPE_VALUE_SALES) { priceList.Party = TheCustomerMgr.LoadCustomer(tbParty.Text.Trim()); } }
public BillGenerator(PriceList priceList, MainOfferHandler mainOfferHandler) { this._priceList = priceList; this._mainOfferHandler = mainOfferHandler; }