Example #1
0
        public bool Delete(int id)
        {
            ProofFile dbEntity = objDataContext.ProofFiles.Where(x => x.ProofFileId == id).FirstOrDefault();

            if (dbEntity != null)
            {
                objDataContext.ProofFiles.Remove(dbEntity);
                objDataContext.SaveChanges();
            }
            return(true);
        }
Example #2
0
        public int Save(ProofFile dao)
        {
            ProofFile entity = objDataContext.ProofFiles.SingleOrDefault(x => x.ProofFileId.Equals(dao.ProofFileId));

            if (entity != null)
            {
                dao.ModifiedAt = DateTimeOffset.Now;
                objDataContext.Entry(entity).CurrentValues.SetValues(dao);
            }
            else
            {
                dao.CreatedAt  = DateTimeOffset.Now;
                dao.ModifiedAt = dao.CreatedAt;
                objDataContext.ProofFiles.Add(dao);
            }
            objDataContext.SaveChanges();
            return(dao.ProofFileId);
        }