Esempio n. 1
0
        public async Task <List <GlueCreateDto1> > GetGlueByBuilding(int buildingID)
        {
            var item     = _repoBuilding.FindById(buildingID);
            var lineList = await _repoBuilding.FindAll().Where(x => x.ParentID == item.ID).Select(x => x.ID).ToListAsync();

            List <int> modelNameID = _repoPlan.FindAll().Where(x => lineList.Contains(x.BuildingID)).Select(x => x.BPFCEstablishID).ToList();
            var        lists       = await _repoGlue.FindAll().ProjectTo <GlueCreateDto1>(_configMapper).Where(x => modelNameID.Contains(x.BPFCEstablishID)).OrderByDescending(x => x.ID).Select(x => new GlueCreateDto1
            {
                ID              = x.ID,
                Name            = x.Name,
                GlueID          = x.GlueID,
                Code            = x.Code,
                ModelNo         = x.ModelNo,
                CreatedDate     = x.CreatedDate,
                BPFCEstablishID = x.BPFCEstablishID,
                PathName        = x.PathName,
                PartNameID      = x.PartNameID,
                MaterialNameID  = x.MaterialNameID,
                MaterialName    = x.MaterialName,
                Consumption     = x.Consumption,
                Chemical        = new GlueDto1 {
                    ID = x.GlueID, Name = x.Name
                }
            }).ToListAsync();

            return(lists.DistinctBy(x => x.Name).ToList());

            //return await _repoGlue.FindAll().ProjectTo<GlueCreateDto1>(_configMapper).Where(x=>x.ModalNameID == modelNameID).OrderByDescending(x => x.ID).ToListAsync();
        }
Esempio n. 2
0
        public async Task <List <BPFCRecordDto> > GetAllBPFCRecord(Status status, string startBuildingDate, string endBuildingDate)
        {
            var lists  = _repoBPFCEstablish.FindAll().ProjectTo <BPFCRecordDto>(_configMapper).OrderByDescending(x => x.ID);
            var result = new List <BPFCRecordDto>();

            if (status == Status.All && !startBuildingDate.IsNullOrEmpty() && !endBuildingDate.IsNullOrEmpty())
            {
                var start = Convert.ToDateTime(startBuildingDate).Date;
                var end   = Convert.ToDateTime(endBuildingDate).Date;
                result = await lists.Where(x => x.BuildingDate.Value.Date >= start && x.BuildingDate.Value.Date <= end).ToListAsync();
            }
            if (status == Status.Done && !startBuildingDate.IsNullOrEmpty() && !endBuildingDate.IsNullOrEmpty())
            {
                var start = Convert.ToDateTime(startBuildingDate).Date;
                var end   = Convert.ToDateTime(endBuildingDate).Date;
                result = await lists.Where(x => x.BuildingDate.Value.Date >= start && x.BuildingDate.Value.Date <= end && x.FinishedStatus == true).ToListAsync();
            }
            if (status == Status.Done)
            {
                result = await lists.Where(x => x.FinishedStatus == true).ToListAsync();
            }
            if (status == Status.All)
            {
                result = await lists.ToListAsync();
            }
            if (!startBuildingDate.IsNullOrEmpty() && !endBuildingDate.IsNullOrEmpty())
            {
                var start = Convert.ToDateTime(startBuildingDate).Date;
                var end   = Convert.ToDateTime(endBuildingDate).Date;
                result = await lists.Where(x => x.BuildingDate.Value.Date >= start && x.BuildingDate.Value.Date <= end).ToListAsync();
            }
            if (result.Count > 0)
            {
                result.ForEach(item =>
                {
                    var glue = _repoGlue.FindAll().FirstOrDefault(x => x.isShow == true && x.BPFCEstablishID == item.ID);
                    if (glue != null)
                    {
                        var ingredient = _repoGlueIngredient.FindAll().Include(x => x.Ingredient).ThenInclude(x => x.Supplier).FirstOrDefault(x => x.GlueID == glue.ID && x.Position == "A");
                        if (ingredient != null)
                        {
                            item.Supplier = ingredient.Ingredient.Supplier.Name ?? "#N/A";
                        }
                        else
                        {
                            item.Supplier = "#N/A";
                        }
                    }
                    else
                    {
                        item.Supplier = "#N/A";
                    }
                });
            }
            return(result);
        }
Esempio n. 3
0
        private async Task <string> GenatateGlueCode(string code)
        {
            int lenght = 8;

            if (await _repoGlue.FindAll().AnyAsync(x => x.Code.Equals(code)) == true)
            {
                var newCode = CodeUtility.RandomString(lenght);
                return(await GenatateGlueCode(newCode));
            }
            return(code);
        }
Esempio n. 4
0
        public async Task <MixingInfo> Mixing(MixingInfoForCreateDto mixing)
        {
            try
            {
                var item = _mapper.Map <MixingInfoForCreateDto, MixingInfo>(mixing);
                item.Code        = CodeUtility.RandomString(8);
                item.CreatedTime = DateTime.Now;
                var glue = await _repoGlue.FindAll().FirstOrDefaultAsync(x => x.isShow == true && x.ID == mixing.GlueID);

                item.ExpiredTime = DateTime.Now.AddMinutes(glue.ExpiredTime);
                _repoMixingInfor.Add(item);
                await _repoMixingInfor.SaveAll();

                // await _repoMixing.AddOrUpdate(item.ID);
                return(item);
            }
            catch
            {
                return(new MixingInfo());
            }
        }
Esempio n. 5
0
        public async Task <PagedList <GlueCreateDto> > GetGluesWithPaginations(PaginationParams param)
        {
            var lists = _repoGlue.FindAll().ProjectTo <GlueCreateDto>(_configMapper).OrderByDescending(x => x.ID);

            return(await PagedList <GlueCreateDto> .CreateAsync(lists, param.PageNumber, param.PageSize));
        }
Esempio n. 6
0
 public async Task <object> GetAllGlues()
 {
     return(await _repoGlue.FindAll().Where(x => x.isShow == true).ProjectTo <GlueCreateDto>(_configMapper).OrderByDescending(x => x.ID).ToListAsync());
 }