Exemplo n.º 1
0
 public ProductSexDto get(string id)
 {
     try
     {
         ProductSex bb = _context.ProductSex.Find(id);
         //               _context.Entry(bb).Reference(b => b.Bank).Load();
         //               _context.Entry(bb).Reference(b => b.Province).Load();
         return(mapper.Map <ProductSex, ProductSexDto>(bb));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemplo n.º 2
0
        public string create(ProductSexDto tProductSexDto)
        {
            try
            {
                ProductSex tProductSexNew = mapper.Map <ProductSexDto, ProductSex>(tProductSexDto);
                tProductSexNew.Id         = Guid.NewGuid().ToString();
                tProductSexNew.CreateDate = DateTime.Now;

                _context.ProductSex.Add(tProductSexNew);
                _context.SaveChanges();
                return("0");
            }
            catch (Exception)
            {
                return("1");
            }
        }
Exemplo n.º 3
0
        public string delete(string id)
        {
            try
            {
                ProductSex tProductSexRemove = _context.ProductSex.Find(id);
                if (tProductSexRemove == null)
                {
                    return("1");
                }

                _context.ProductSex.Remove(tProductSexRemove);
                _context.SaveChanges();
                return("0");
            }
            catch (Exception)
            {
                return("1");
            }
        }
Exemplo n.º 4
0
        public string lockItem(string id)
        {
            try
            {
                ProductSex tProductSexBlock = _context.ProductSex.Find(id);
                if (tProductSexBlock == null)
                {
                    return("1");
                }
                tProductSexBlock.Status = false;

                _context.ProductSex.Update(tProductSexBlock);
                _context.SaveChanges();
                return("0");
            }
            catch (Exception)
            {
                return("1");
            }
        }
Exemplo n.º 5
0
        //Update
        public string update(ProductSexDto tProductSexDto)
        {
            try
            {
                ProductSex tProductSexUpdate = _context.ProductSex.Find(tProductSexDto.Id);
                if (tProductSexUpdate == null)
                {
                    return("1");
                }
                tProductSexUpdate.Name       = tProductSexDto.Name;
                tProductSexUpdate.Id         = tProductSexDto.Id;
                tProductSexUpdate.Status     = tProductSexDto.Status;
                tProductSexUpdate.CreateDate = tProductSexDto.CreateDate;
                tProductSexUpdate.CreateUser = tProductSexDto.CreateUser;

                _context.ProductSex.Update(tProductSexUpdate);
                _context.SaveChanges();
                return("0");
            }
            catch (Exception)
            {
                return("1");
            }
        }