Ejemplo n.º 1
0
        //Cập nhật Brand
        public async Task <bool> Update(GlueCreateDto model)
        {
            var glue = _mapper.Map <Glue>(model);

            _repoGlue.Update(glue);
            return(await _repoGlue.SaveAll());
        }
Ejemplo n.º 2
0
 public async Task <IActionResult> Update(GlueCreateDto glueIngredientDto)
 {
     glueIngredientDto.CreatedDate = DateTime.Now.ToString("MMMM dd, yyyy HH:mm:ss tt");
     if (await _glueService.Update(glueIngredientDto))
     {
         return(NoContent());
     }
     return(BadRequest($"Updating brand {glueIngredientDto.ID} failed on save"));
 }
Ejemplo n.º 3
0
        //Cập nhật Brand
        public async Task <bool> Update(GlueCreateDto model)
        {
            var glue = _mapper.Map <Glue>(model);

            _repoGlue.Update(glue);
            var result = await _repoGlue.SaveAll();

            await _hubContext.Clients.All.SendAsync("summaryRecieve", "ok");

            return(result);
        }
Ejemplo n.º 4
0
        //Cập nhật Brand
        public async Task <bool> UpdateChemical(GlueCreateDto model)
        {
            var glue = _mapper.Map <Glue>(model);

            _repoGlue.Update(glue);
            var item = _repoGlueIngredient.FindAll().FirstOrDefault(x => x.GlueID.Equals(model.ID) && x.Percentage == 100);

            if (item != null)
            {
                item.IngredientID = model.IngredientID;
                return(await _repoGlue.SaveAll());
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create(GlueCreateDto glueIngredientDto)
        {
            if (await _glueService.CheckExists(glueIngredientDto.ID))
            {
                return(BadRequest("Glue ID already exists!"));
            }
            if (await _glueService.CheckBarCodeExists(glueIngredientDto.Code))
            {
                return(BadRequest("Barcode already exists!"));
            }
            //var username = User.FindFirst(ClaimTypes.Name).Value;
            glueIngredientDto.CreatedDate = DateTime.Now.ToString("MMMM dd, yyyy HH:mm:ss tt");
            if (await _glueService.Add(glueIngredientDto))
            {
                return(NoContent());
            }

            throw new Exception("Creating the brand failed on save");
        }
Ejemplo n.º 6
0
        //Thêm Brand mới vào bảng Glue
        public async Task <bool> Add(GlueCreateDto model)
        {
            var glue = _mapper.Map <Glue>(model);

            glue.Code = await GenatateGlueCode(glue.Code);

            glue.CreatedDate = DateTime.Now.ToString("MMMM dd, yyyy HH:mm:ss tt");
            var nameList = new List <int>();

            foreach (var item in _repoGlue.FindAll().Where(x => x.BPFCEstablishID == model.BPFCEstablishID))
            {
                if (item.Name.Length == 1 || item.Name.Length == 2)
                {
                    nameList.Add(item.Name.ToInt());
                }
            }
            var name = nameList.OrderByDescending(x => x).FirstOrDefault();

            glue.Name = (name + 1).ToString();
            _repoGlue.Add(glue);

            return(await _repoGlue.SaveAll());
        }