Пример #1
0
        private List<ResourceDto> CopyResources(IEnumerable<ResourceDto> resources)
        {
            var resourcesCollection = new List<ResourceDto>();

            foreach (var tmpResource in resources)
            {
                var resource = new ResourceDto
                {
                    Amount = tmpResource.Amount,
                    Code = tmpResource.Code,
                    Cost = tmpResource.Cost,
                    Id = tmpResource.Id,
                    Measure = tmpResource.Measure,
                    MeasureId = tmpResource.MeasureId,
                    Name = tmpResource.Name,
                    RealUsed = tmpResource.RealUsed,
                    ResourceType = tmpResource.ResourceType,
                    ResourceTypeId = tmpResource.ResourceTypeId,
                    TotalCost = tmpResource.TotalCost
                };
                resourcesCollection.Add(resource);
            }
            return resourcesCollection;
        }
Пример #2
0
 private void Map(ResourceDto source, PRE_DETALLE destination)
 {
     destination.PRD_ID = 1; // No tengo ni idea de que es este id o como se llena
     destination.CIA_CODIGO = "01";
     destination.HOP_CODIGO = GetBudgetSheet(source.ResourceType.Name);
     destination.INV_CODIGO = source.Code;
     destination.PRD_DESCRIPCION = source.Name;
     destination.PRD_COSTOUNITARIO = Convert.ToDouble(source.Cost);
     destination.PRD_CANTIDAD = source.Amount;
     destination.PRD_COSTOTOTAL = Convert.ToDouble(source.TotalCost);
     destination.PRD_APLICARIMPVTAS = 0;
 }
Пример #3
0
        private ResourceDto OnlyOneFromSeveral(List<ResourceDto> resourceCollection)
        {
            var item = new ResourceDto();

            if (resourceCollection != null)
            {
                item = resourceCollection.First();
                var amount = resourceCollection.Sum(x => x.Amount);
                var totalCost = resourceCollection.Sum(x => x.TotalCost);
                item.Amount = amount;
                item.TotalCost = totalCost;
            }
            return item;
        }
Пример #4
0
        private bool CheckRepeatItem(ResourceDto resource)
        {
            var count = 0;

            if (viewResources.DataSource != null)
                foreach (var tmpResource in (IEnumerable<ResourceDto>)viewResources.DataSource)
                {
                    if ((resource.Code == tmpResource.Code) && (resource.ResourceType.Id == tmpResource.ResourceType.Id))
                        count++;
                }

            return count > 1;
        }