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); } }
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"); } }
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"); } }
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"); } }
//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"); } }