public ArticleSubFamilyPricePartnersResponse Delete(ArticleSubFamilyPricePartners request) { Bm2s.Data.Common.BLL.Article.ArticleSubFamilyPricePartner item = Datas.Instance.DataStorage.ArticleSubFamilyPricePartners[request.ArticleSubFamilyPricePartner.Id]; item.EndingDate = DateTime.Now; Datas.Instance.DataStorage.ArticleSubFamilyPricePartners[item.Id] = item; ArticleSubFamilyPricePartnersResponse response = new ArticleSubFamilyPricePartnersResponse(); response.ArticleSubFamilyPricePartners.Add(request.ArticleSubFamilyPricePartner); return response; }
public ArticleSubFamilyPricePartnersResponse Get(ArticleSubFamilyPricePartners request) { ArticleSubFamilyPricePartnersResponse response = new ArticleSubFamilyPricePartnersResponse(); List<Bm2s.Data.Common.BLL.Article.ArticleSubFamilyPricePartner> items = new List<Data.Common.BLL.Article.ArticleSubFamilyPricePartner>(); if (!request.Ids.Any()) { items.AddRange(Datas.Instance.DataStorage.ArticleSubFamilyPricePartners.Where(item => (request.PartnerId == 0 || item.PartnerId == request.PartnerId) && (request.ArticleSubFamilyId == 0 || item.ArticleSubFamilyId == request.ArticleSubFamilyId) && (!request.Date.HasValue || (request.Date >= item.StartingDate && (!item.EndingDate.HasValue || request.Date < item.EndingDate.Value))) )); } else { items.AddRange(Datas.Instance.DataStorage.ArticleSubFamilyPricePartners.Where(item => request.Ids.Contains(item.Id))); } var collection = (from item in items select new Bm2s.Poco.Common.Article.ArticleSubFamilyPricePartner() { AddPrice = item.AddPrice, ArticleSubFamily = new ArticleSubFamiliesService().Get(new ArticleSubFamilies() { Ids = new List<int>() { item.ArticleSubFamilyId } }).ArticleSubFamilies.FirstOrDefault(), EndingDate = item.EndingDate, Id = item.Id, Multiplier = Convert.ToDecimal(item.Multiplier), Partner = new PartnersService().Get(new Partners() { Ids = new List<int>() { item.PartnerId } }).Partners.FirstOrDefault(), Price = Convert.ToDecimal(item.Price), StartingDate = item.StartingDate }).AsQueryable().OrderBy(request.Order, !request.DescendingOrder); response.ItemsCount = collection.Count(); if (request.PageSize > 0) { response.ArticleSubFamilyPricePartners.AddRange(collection.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize)); } else { response.ArticleSubFamilyPricePartners.AddRange(collection); } try { response.PagesCount = collection.Count() / response.ArticleSubFamilyPricePartners.Count + (collection.Count() % response.ArticleSubFamilyPricePartners.Count > 0 ? 1 : 0); } catch { response.PagesCount = 1; } return response; }
public ArticleSubFamilyPricePartnersResponse Post(ArticleSubFamilyPricePartners request) { if (request.ArticleSubFamilyPricePartner.Id > 0) { Bm2s.Data.Common.BLL.Article.ArticleSubFamilyPricePartner item = Datas.Instance.DataStorage.ArticleSubFamilyPricePartners[request.ArticleSubFamilyPricePartner.Id]; item.AddPrice = request.ArticleSubFamilyPricePartner.AddPrice; item.ArticleSubFamilyId = request.ArticleSubFamilyPricePartner.ArticleSubFamily.Id; item.EndingDate = request.ArticleSubFamilyPricePartner.EndingDate; item.Multiplier = Convert.ToDouble(request.ArticleSubFamilyPricePartner.Multiplier); item.PartnerId = request.ArticleSubFamilyPricePartner.Partner.Id; item.Price = Convert.ToDouble(request.ArticleSubFamilyPricePartner.Price); item.StartingDate = request.ArticleSubFamilyPricePartner.StartingDate; Datas.Instance.DataStorage.ArticleSubFamilyPricePartners[request.ArticleSubFamilyPricePartner.Id] = item; } else { Bm2s.Data.Common.BLL.Article.ArticleSubFamilyPricePartner item = new Data.Common.BLL.Article.ArticleSubFamilyPricePartner() { AddPrice = request.ArticleSubFamilyPricePartner.AddPrice, ArticleSubFamilyId = request.ArticleSubFamilyPricePartner.ArticleSubFamily.Id, EndingDate = request.ArticleSubFamilyPricePartner.EndingDate, Multiplier = Convert.ToDouble(request.ArticleSubFamilyPricePartner.Multiplier), PartnerId = request.ArticleSubFamilyPricePartner.Partner.Id, Price = Convert.ToDouble(request.ArticleSubFamilyPricePartner.Price), StartingDate = request.ArticleSubFamilyPricePartner.StartingDate }; Datas.Instance.DataStorage.ArticleSubFamilyPricePartners.Add(item); request.ArticleSubFamilyPricePartner.Id = item.Id; } ArticleSubFamilyPricePartnersResponse response = new ArticleSubFamilyPricePartnersResponse(); response.ArticleSubFamilyPricePartners.Add(request.ArticleSubFamilyPricePartner); return response; }
public void Post() { this.Response = this.ConnectorHelper.Post(this.Request); this.IsFilled = true; }
public void Delete() { this.Response = this.ConnectorHelper.Delete(this.Request); this.IsFilled = true; }