public void CreateOrUpdate(ApplicationDbContext context, string userId) { VolunteerHours volunteerHours = context.VolunteerHours.Find(Id); DateTime dateTime = VollyConstants.ConvertToUtc(DateTime); if (volunteerHours != null) { volunteerHours.Hours = Hours; volunteerHours.DateTime = dateTime; volunteerHours.OpportunityName = OpportunityName; volunteerHours.OrganizationName = OrganizationName; } else { VolunteerHours newVolunteerHours = new VolunteerHours() { OpportunityName = OpportunityName, OrganizationName = OrganizationName, DateTime = dateTime, Hours = Hours, UserId = userId }; context.Add(newVolunteerHours); } context.SaveChanges(); }
public static Func <Occurrence, Occurrence> ConvertToUtc() { return(delegate(Occurrence occurrence) { occurrence.StartTime = VollyConstants.ConvertToUtc(occurrence.StartTime); occurrence.EndTime = VollyConstants.ConvertToUtc(occurrence.EndTime); occurrence.ApplicationDeadline = VollyConstants.ConvertToUtc(occurrence.ApplicationDeadline); return occurrence; }); }