public HeaderFilesResponse Delete(HeaderFiles request)
        {
            Bm2s.Data.Common.BLL.Trade.HeaderFile item = Datas.Instance.DataStorage.HeaderFiles[request.HeaderFile.Id];
              Datas.Instance.DataStorage.HeaderFiles.Remove(item);

              HeaderFilesResponse response = new HeaderFilesResponse();
              response.HeaderFiles.Add(request.HeaderFile);
              return response;
        }
        public HeaderFilesResponse Get(HeaderFiles request)
        {
            HeaderFilesResponse response = new HeaderFilesResponse();
              List<Bm2s.Data.Common.BLL.Trade.HeaderFile> items = new List<Data.Common.BLL.Trade.HeaderFile>();
              if (!request.Ids.Any())
              {
            items.AddRange(Datas.Instance.DataStorage.HeaderFiles.Where(item =>
              (request.HeaderId == 0 || item.HeaderId == request.HeaderId) &&
              (string.IsNullOrWhiteSpace(request.Name) || item.Name.ToLower().Contains(request.Name.ToLower())) &&
              (request.UserId == 0 || item.UserId == request.UserId) &&
              (!request.AddingDate.HasValue || request.AddingDate >= item.AddingDate)
              ));
              }
              else
              {
            items.AddRange(Datas.Instance.DataStorage.HeaderFiles.Where(item => request.Ids.Contains(item.Id)));
              }

              var collection = (from item in items
                        select new Bm2s.Poco.Common.Trade.HeaderFile()
                        {
                          AddingDate = item.AddingDate,
                          Content = item.Content,
                          Header = new HeadersService().Get(new Headers() { Ids = new List<int>() { item.HeaderId } }).Headers.FirstOrDefault(),
                          Id = item.Id,
                          Name = item.Name,
                          User = new UsersService().Get(new Users() { Ids = new List<int>() { item.UserId } }).Users.FirstOrDefault()
                        }).AsQueryable().OrderBy(request.Order, !request.DescendingOrder);

              response.ItemsCount = collection.Count();
              if (request.PageSize > 0)
              {
            response.HeaderFiles.AddRange(collection.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize));
              }
              else
              {
            response.HeaderFiles.AddRange(collection);
              }

              try
              {
            response.PagesCount = collection.Count() / response.HeaderFiles.Count + (collection.Count() % response.HeaderFiles.Count > 0 ? 1 : 0);
              }
              catch
              {
            response.PagesCount = 1;
              }

              return response;
        }
        public HeaderFilesResponse Post(HeaderFiles request)
        {
            if (request.HeaderFile.Id > 0)
              {
            Bm2s.Data.Common.BLL.Trade.HeaderFile item = Datas.Instance.DataStorage.HeaderFiles[request.HeaderFile.Id];
            item.AddingDate = request.HeaderFile.AddingDate;
            item.Content = request.HeaderFile.Content;
            item.HeaderId = request.HeaderFile.Header.Id;
            item.Name = request.HeaderFile.Name;
            item.UserId = request.HeaderFile.User.Id;
            Datas.Instance.DataStorage.HeaderFiles[request.HeaderFile.Id] = item;
              }
              else
              {
            Bm2s.Data.Common.BLL.Trade.HeaderFile item = new Data.Common.BLL.Trade.HeaderFile()
            {
              AddingDate = request.HeaderFile.AddingDate,
              Content = request.HeaderFile.Content,
              HeaderId = request.HeaderFile.Header.Id,
              Name = request.HeaderFile.Name,
              UserId = request.HeaderFile.User.Id
            };

            Datas.Instance.DataStorage.HeaderFiles.Add(item);
            request.HeaderFile.Id = item.Id;
              }

              HeaderFilesResponse response = new HeaderFilesResponse();
              response.HeaderFiles.Add(request.HeaderFile);
              return response;
        }
Пример #4
0
 public void Post()
 {
     this.Response = this.ConnectorHelper.Post(this.Request);
       this.IsFilled = true;
 }
Пример #5
0
 public void Delete()
 {
     this.Response = this.ConnectorHelper.Delete(this.Request);
       this.IsFilled = true;
 }