public int PutClassificationSet(ABC_ClassificationSetDTO obj) { obj.ThoiGianApDung = obj.ThoiGianApDung?.ToLocalTime(); try { int result = 0; SessionManager.DoWork(session => { if (obj.Id == Guid.Empty) { ABC_ClassificationSet newItem = new ABC_ClassificationSet(); newItem.Id = Guid.NewGuid(); newItem.Name = obj.Name; newItem.ThoiGianApDung = obj.ThoiGianApDung; session.Save(newItem); } else { var objDB = session.Query <ABC_ClassificationSet>().SingleOrDefault(q => q.Id == obj.Id); objDB.Name = obj.Name; objDB.ThoiGianApDung = obj.ThoiGianApDung; session.Update(objDB); } result = 1; }); return(result); } catch (Exception) { throw; } }
public int DeleteClassificationSet(ABC_ClassificationSetDTO item) { try { SessionManager.DoWork(session => { var obj = session.Query <ABC_ClassificationSet>().SingleOrDefault(q => q.Id == item.Id); if (obj != null) { session.Delete(obj); } }); return(1); } catch (Exception) { throw; } }