public bool UpdateUser(EPUser user) { MainUnitOfWork unitOfWork = new MainUnitOfWork(); unitOfWork.Begin(); unitOfWork.Session.Update(user); unitOfWork.Commit(); return true; }
public EPUser RegisterUser(EPUser user) { MainUnitOfWork unitOfWork = new MainUnitOfWork(); unitOfWork.Begin(); user.Id = (int)unitOfWork.Session.Save(user); unitOfWork.Commit(); return user; }
public bool UpdateUserPassword(string username, string password) { MainUnitOfWork unitOfWork = new MainUnitOfWork(); var user = unitOfWork.Session.QueryOver<EPUser>().Where(p => p.Username == username).SingleOrDefault(); user.Password = password; unitOfWork.Begin(); unitOfWork.Session.Update(user); unitOfWork.Commit(); return true; }
public bool FinishJob(int jobId, int emailCount, int smsCount) { var unitOfWork = new MainUnitOfWork(); unitOfWork.Begin(); Job job = unitOfWork.Session.Get<Job>(jobId); job.EndDate = DateTime.Now; job.EmailSent = emailCount; job.SmsSent = smsCount; job.StatusId = (int)JobStatus.JobCompleted; unitOfWork.Session.Update(job); unitOfWork.Commit(); return true; }
public bool IsLastJobCompleted() { var unitOfWork = new MainUnitOfWork(); unitOfWork.Begin(); var jobs = unitOfWork.Session.QueryOver<Job>().OrderBy(p => p.Id).Desc.List(); if (jobs == null || jobs.Count == 0) { return true; } else if (jobs.First().StatusId == (int)JobStatus.JobCompleted) { return true; } return false; }
public int AddJob(int emailBatchSize, int smsBatchSize) { var unitOfWork = new MainUnitOfWork(); unitOfWork.Begin(); Job job = new Job { Name = "JOB" + DateTime.Now.Ticks, StartDate = DateTime.Now, EmailBatch = emailBatchSize, SmsBatch = smsBatchSize, StatusId = (int)JobStatus.JobStarted }; var id = (int)unitOfWork.Session.Save(job); unitOfWork.Commit(); return id; }