public TimeSheetViewModel(TimeSheetEntity timeSheet) { if (timeSheet == null) { return; } TimeSheetId = timeSheet.Id; Date = timeSheet.Date; TaskDescription = timeSheet.TaskDescription; RegularHours = timeSheet.RegularHours; OverTimeHours = timeSheet.OverTimeHours; CustomerId = timeSheet.CustomerId; ProjectId = timeSheet.ProjectId; Customer = new CustomerViewModel(timeSheet.Customer); Project = new ProjectViewModel(timeSheet.Project); }
protected override void Seed(TimeSheetContext context) { if (context.Customers.Any()) { return; } // Creating some projects var projectOne = new ProjectEntity() { Id = 1, Name = "Boring Project", Description = "A very boring project" }; var projectTwo = new ProjectEntity() { Id = 2, Name = "Amazing Project", Description = "A very exciting project" }; // Creating some projects var projectThree = new ProjectEntity() { Id = 3, Name = "The Project of the life", Description = "This is a very beautiful project" }; var projectFour = new ProjectEntity() { Id = 4, Name = "Normal Project", Description = "Common fun project" }; // Creating a customer var customer = new CustomerEntity() { Id = 1, FirstName = "Mark", LastName = "Zuckerberg", Address = "1 Hacker Way, 94025 Menlo Park, CA", Email = "*****@*****.**" }; context.Customers.AddOrUpdate(customer); // Creating a customer var customerTwo = new CustomerEntity() { Id = 2, FirstName = "", LastName = "Software House", Address = "Via Delle vie, 14, Milano", Email = "*****@*****.**" }; context.Customers.AddOrUpdate(customerTwo); //Create a record on timesheet var timeSheet = new TimeSheetEntity(); timeSheet.Project = projectOne; timeSheet.Customer = customer; timeSheet.Date = DateTime.Now; timeSheet.TaskDescription = "Backend bug fixing"; timeSheet.RegularHours = 8; timeSheet.OverTimeHours = 2; context.TimeSheets.AddOrUpdate(timeSheet); //Create a record on timesheet timeSheet = new TimeSheetEntity(); timeSheet.Project = projectTwo; timeSheet.Customer = customer; timeSheet.Date = DateTime.Now; timeSheet.TaskDescription = "Frontend bug fixing"; timeSheet.RegularHours = 8; timeSheet.OverTimeHours = 3; context.TimeSheets.AddOrUpdate(timeSheet); //Create a record on timesheet timeSheet = new TimeSheetEntity(); timeSheet.Project = projectThree; timeSheet.Customer = customerTwo; timeSheet.Date = DateTime.Now; timeSheet.TaskDescription = "Bug fixing and staging deploy"; timeSheet.RegularHours = 8; timeSheet.OverTimeHours = 1; context.TimeSheets.AddOrUpdate(timeSheet); //Create a record on timesheet timeSheet = new TimeSheetEntity(); timeSheet.Project = projectFour; timeSheet.Customer = customerTwo; timeSheet.Date = DateTime.Now; timeSheet.TaskDescription = "Bug fixing and production deploy"; timeSheet.RegularHours = 11; timeSheet.OverTimeHours = 1; context.TimeSheets.AddOrUpdate(timeSheet); context.SaveChanges(); }
public void Delete(TimeSheetEntity entity) { _dataContext.Entry(entity).State = EntityState.Deleted; }
public void Edit(TimeSheetEntity entity) { _dataContext.Entry(entity).State = EntityState.Modified; }
public TimeSheetEntity Add(TimeSheetEntity entity) { return(_dbSet.Add(entity)); }