Exemplo n.º 1
0
        public string create(ProductAgeDto tProductAgeDto)
        {
            try
            {
                ProductAge tProductAgeNew = mapper.Map <ProductAgeDto, ProductAge>(tProductAgeDto);
                tProductAgeNew.Id         = Guid.NewGuid().ToString();
                tProductAgeNew.CreateDate = DateTime.Now;

                _context.ProductAge.Add(tProductAgeNew);
                _context.SaveChanges();
                return("0");
            }
            catch (Exception)
            {
                return("1");
            }
        }
Exemplo n.º 2
0
        public string update(ProductAgeDto tProductAgeDto)
        {
            try
            {
                ProductAge tProductAgeBranchUpdate = _context.ProductAge.Find(tProductAgeDto.Id);
                if (tProductAgeBranchUpdate == null)
                {
                    return("1");
                }
                tProductAgeBranchUpdate.Id         = tProductAgeDto.Id;
                tProductAgeBranchUpdate.Name       = tProductAgeDto.Name;
                tProductAgeBranchUpdate.Status     = tProductAgeDto.Status;
                tProductAgeBranchUpdate.CreateDate = tProductAgeDto.CreateDate;


                _context.ProductAge.Update(tProductAgeBranchUpdate);
                _context.SaveChanges();
                return("0");
            }
            catch (Exception)
            {
                return("1");
            }
        }
Exemplo n.º 3
0
        public IActionResult Update([FromBody] ProductAgeDto value)
        {
            string result = _productAge.update(value);

            return(new ObjectResult(result));
        }