public void AddJobType(JobTypeModelView jobtype) { using (SchedulerEntities db = new SchedulerEntities()) { JOBTYPE JT = new JOBTYPE(); JT.CreatedBy = HttpContext.Current.User.Identity.Name; JT.LastModifiedBy = HttpContext.Current.User.Identity.Name; JT.CreationDate = DateTime.Now; JT.ID = Guid.NewGuid(); JT.Duration = jobtype.Duration; JT.Unit = jobtype.Unit; JT.Rate = jobtype.Rate; JT.SkillRequired = jobtype.SkillRequired; JT.WorkersRequired = jobtype.WorkersRequired; JT.Tools = jobtype.Tools; JT.ToolCost = jobtype.ToolsCost; JT.FacilitiesRequired = jobtype.FacilitiesRequired; JT.FacilitiesCost = jobtype.FacilitiesCost; JT.Description = jobtype.Description; JT.JobPrice = jobtype.JobPrice; db.JOBTYPEs.Add(JT); db.SaveChanges(); } }
public static void DeleteEnrollment(int id) { using (var db = new SchedulerEntities()) { var dbEnrollment = new Entrollments { EnrollmentId = id }; db.Entry(dbEnrollment).State = EntityState.Deleted; db.SaveChanges(); } }
public static void CreateCourse(CourseViewModel course) { using (var db = new SchedulerEntities()) { var dbCourse = new Courses { Name = course.Name }; db.Courses.Add(dbCourse); db.SaveChanges(); } }
public static void CreateEnrollment(CreateEnrollmentVm enrollment) { using (var db = new SchedulerEntities()) { var dbEnrollment = new Entrollments { Course_Fk = enrollment.CourseId, Person_Fk = enrollment.ParticipantId }; db.Entrollments.Add(dbEnrollment); db.SaveChanges(); } }
public static void CreateParticipant(ParticipantsViewModel participant) { using (var db = new SchedulerEntities()) { var dbPerson = new Persons { Name = participant.Name, Username = participant.Username, Password = participant.Password, IsAdmin = participant.IsAdmin }; db.Persons.Add(dbPerson); db.SaveChanges(); } }
public void DeleteUser(int userID) { using (SchedulerEntities db = new SchedulerEntities()) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { var SUR = db.SYSUserRoles.Where(o => o.SYSUserID == userID); if (SUR.Any()) { db.SYSUserRoles.Remove(SUR.FirstOrDefault()); db.SaveChanges(); } var SUP = db.SYSUserProfiles.Where(o => o.SYSUserID == userID); if (SUP.Any()) { db.SYSUserProfiles.Remove(SUP.FirstOrDefault()); db.SaveChanges(); } var SU = db.SYSUsers.Where(o => o.SYSUserID == userID); if (SU.Any()) { db.SYSUsers.Remove(SU.FirstOrDefault()); db.SaveChanges(); } dbContextTransaction.Commit(); } catch { dbContextTransaction.Rollback(); } } } }
public static void Reschedule() { Graph.PopulateGraph(); Graph.ColorGraph(); using (var db = new SchedulerEntities()) { db.Database.ExecuteSqlCommand("TRUNCATE TABLE [Colors]"); db.Colors.AddRange(Graph.GraphInstance.Vertices.Select(cl => new Colors { Course_Fk = cl.Id, Day = cl.Color.Day, TimeSlot = cl.Color.TimeSlot }).AsEnumerable()); db.SaveChanges(); } }
public static void DeleteCourse(CourseViewModel course) { using (var db = new SchedulerEntities()) { var dbCourse = db.Courses.Find(course.CourseId); if (dbCourse == null) { throw new DataException( "The table Course does not contain an entry corresponding to the provided primary key"); } db.Courses.Remove(dbCourse); db.SaveChanges(); } }
public static void DeleteParticipant(ParticipantsViewModel participant) { using (var db = new SchedulerEntities()) { var dbPerson = db.Persons.Find(participant.PersonId); if (dbPerson == null) { throw new DataException( "The table Course does not contain an entry corresponding to the provided primary key"); } db.Persons.Remove(dbPerson); db.SaveChanges(); } }
public void DeleteJob(Guid jobID) { using (SchedulerEntities db = new SchedulerEntities()) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { var SUR = db.JOBWORKERs.Where(o => o.JobId == jobID.ToString()); if (SUR.Any()) { db.JOBWORKERs.Remove(SUR.FirstOrDefault()); db.SaveChanges(); } var TUR = db.JOBTOOLs.Where(t => t.JobId == jobID.ToString()); if (SUR.Any()) { db.JOBTOOLs.Remove(TUR.FirstOrDefault()); db.SaveChanges(); } var JUR = db.JOBs.Where(t => t.ID == jobID); if (SUR.Any()) { db.JOBs.Remove(JUR.FirstOrDefault()); db.SaveChanges(); } dbContextTransaction.Commit(); } catch { dbContextTransaction.Rollback(); } } } }
public void AddJobTool(JobTool jt) { using (SchedulerEntities db = new SchedulerEntities()) { JOBTOOL JT = new JOBTOOL(); JT.CreatedBy = HttpContext.Current.User.Identity.Name; JT.LastModifiedBy = HttpContext.Current.User.Identity.Name; JT.CreationDate = DateTime.Now; JT.ToolId = jt.ToolId; JT.JobId = jt.JobId; db.JOBTOOLs.Add(JT); db.SaveChanges(); } }
public void AddJobTool(UserSignUpView user) { using (SchedulerEntities db = new SchedulerEntities()) { SYSUser SU = new SYSUser(); SU.LoginName = user.LoginName; SU.PasswordEncryptedText = user.Password; SU.RowCreatedSYSUserID = user.SYSUserID > 0 ? user.SYSUserID : 1; SU.RowModifiedSYSUserID = user.SYSUserID > 0 ? user.SYSUserID : 1;; SU.RowCreatedDateTime = DateTime.Now; SU.RowModifiedDateTime = DateTime.Now; db.SYSUsers.Add(SU); db.SaveChanges(); } }
public void AddJobWorker(JobWorker jw) { using (SchedulerEntities db = new SchedulerEntities()) { JOBWORKER JW = new JOBWORKER(); JW.CreatedBy = HttpContext.Current.User.Identity.Name; JW.LastModifiedBy = HttpContext.Current.User.Identity.Name; JW.CreationDate = DateTime.Now; JW.WorkerId = jw.WorkerId; JW.JobId = jw.JobId; db.JOBWORKERs.Add(JW); db.SaveChanges(); } }
public void AddJob(JobModelView user) { using (SchedulerEntities db = new SchedulerEntities()) { JOB SU = new JOB(); SU.ID = user.ID; SU.JobTypeID = user.JobTypeID; SU.CreatedBy = HttpContext.Current.User.Identity.Name; SU.LastModifiedBy = HttpContext.Current.User.Identity.Name; SU.CreationDate = DateTime.Now; SU.Description = user.Description; SU.CustomerID = user.CustomerID; SU.Cost = user.Cost; db.SaveChanges(); } }
public void AddCustomer(CustomerModelView user) { using (SchedulerEntities db = new SchedulerEntities()) { CUSTOMER CU = new CUSTOMER(); CU.CreatedBy = HttpContext.Current.User.Identity.Name; CU.LastModifiedBy = HttpContext.Current.User.Identity.Name; CU.CreationDate = DateTime.Now; CU.ID = Guid.NewGuid(); CU.Firstname = user.Firstname; CU.Lastname = user.Lastname; CU.Address = user.Address; CU.Email = user.Email; CU.Mobile = user.Mobile; CU.Notes = user.Notes; db.CUSTOMERs.Add(CU); db.SaveChanges(); } }
public void DeleteAssignment(string strJobId, string strAssignmentId, string assignmentType) { using (SchedulerEntities db = new SchedulerEntities()) { using (var dbContextTransaction = db.Database.BeginTransaction()) { if (assignmentType == "workerlist") { try { var SUR = db.JOBWORKERs.Where(o => o.WorkerId == strAssignmentId && o.JobId == strJobId); if (SUR.Any()) { db.JOBWORKERs.Remove(SUR.FirstOrDefault()); db.SaveChanges(); } dbContextTransaction.Commit(); } catch { dbContextTransaction.Rollback(); } } else if (assignmentType == "toollist") { try { var SUR = db.JOBTOOLs.Where(o => o.ToolId == strAssignmentId && o.JobId == strJobId); if (SUR.Any()) { db.JOBTOOLs.Remove(SUR.FirstOrDefault()); db.SaveChanges(); } dbContextTransaction.Commit(); } catch { dbContextTransaction.Rollback(); } } else if (assignmentType.Substring(0, 4) == "book") { try { var JBLK = db.JOBBLOCKs.Where(o => o.JobId == strAssignmentId); if (JBLK.Any()) { db.JOBBLOCKs.Remove(JBLK.FirstOrDefault()); db.SaveChanges(); } dbContextTransaction.Commit(); } catch { dbContextTransaction.Rollback(); } } else if (assignmentType == "joblist") { try { var SUR = db.JOBWORKERs.Where(o => o.JobId == strAssignmentId); if (SUR.Any()) { db.JOBWORKERs.Remove(SUR.FirstOrDefault()); db.SaveChanges(); } var TUR = db.JOBTOOLs.Where(t => t.JobId == strAssignmentId); if (TUR.Any()) { db.JOBTOOLs.Remove(TUR.FirstOrDefault()); db.SaveChanges(); } var JUR = db.JOBs.Where(t => t.ID.ToString() == strAssignmentId); if (JUR.Any()) { db.JOBs.Remove(JUR.FirstOrDefault()); db.SaveChanges(); } dbContextTransaction.Commit(); } catch { dbContextTransaction.Rollback(); } } } } }
public void UpdateJob(UserProfileView user) { using (SchedulerEntities db = new SchedulerEntities()) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { SYSUser SU = db.SYSUsers.Find(user.SYSUserID); SU.LoginName = user.LoginName; SU.PasswordEncryptedText = user.Password; SU.RowCreatedSYSUserID = user.SYSUserID; SU.RowModifiedSYSUserID = user.SYSUserID; SU.RowCreatedDateTime = DateTime.Now; SU.RowModifiedDateTime = DateTime.Now; db.SaveChanges(); var userProfile = db.SYSUserProfiles.Where(o => o.SYSUserID == user.SYSUserID); if (userProfile.Any()) { SYSUserProfile SUP = userProfile.FirstOrDefault(); SUP.SYSUserID = SU.SYSUserID; SUP.FirstName = user.FirstName; SUP.LastName = user.LastName; SUP.Gender = user.Gender; SUP.RowCreatedSYSUserID = user.SYSUserID; SUP.RowModifiedSYSUserID = user.SYSUserID; SUP.RowCreatedDateTime = DateTime.Now; SUP.RowModifiedDateTime = DateTime.Now; db.SaveChanges(); } if (user.LOOKUPRoleID > 0) { var userRole = db.SYSUserRoles.Where(o => o.SYSUserID == user.SYSUserID); SYSUserRole SUR = null; if (userRole.Any()) { SUR = userRole.FirstOrDefault(); SUR.LOOKUPRoleID = user.LOOKUPRoleID; SUR.SYSUserID = user.SYSUserID; SUR.IsActive = true; SUR.RowCreatedSYSUserID = user.SYSUserID; SUR.RowModifiedSYSUserID = user.SYSUserID; SUR.RowCreatedDateTime = DateTime.Now; SUR.RowModifiedDateTime = DateTime.Now; } else { SUR = new SYSUserRole(); SUR.LOOKUPRoleID = user.LOOKUPRoleID; SUR.SYSUserID = user.SYSUserID; SUR.IsActive = true; SUR.RowCreatedSYSUserID = user.SYSUserID; SUR.RowModifiedSYSUserID = user.SYSUserID; SUR.RowCreatedDateTime = DateTime.Now; SUR.RowModifiedDateTime = DateTime.Now; db.SYSUserRoles.Add(SUR); } db.SaveChanges(); } dbContextTransaction.Commit(); } catch { dbContextTransaction.Rollback(); } } } }