public bool SaveBlog(Blog entity) { if (entity.Id == default) { _context.Entry(entity).State = EntityState.Added; } else { _context.Entry(entity).State = EntityState.Modified; } _context.SaveChanges(); return(true); }
public bool SaveTrainerCategory(TrainerCategory entity) { if (!ContainsTrainerCategoryByName(entity.Name)) { if (entity.Id == default) { _context.Entry(entity).State = EntityState.Added; } else { _context.Entry(entity).State = EntityState.Modified; } _context.SaveChanges(); return(true); } return(false); }
public bool SaveGender(Gender entity) { if (!ContainsGenderByName(entity.Name)) { if (entity.Id == default) { _context.Entry(entity).State = EntityState.Added; } else { _context.Entry(entity).State = EntityState.Modified; } _context.SaveChanges(); return(true); } return(false); }
public bool SaveTestimonial(Testimonial entity) { if (entity.Id == default) { if (!ContainsTestimonialByClientId(entity.ClientId)) { _context.Entry(entity).State = EntityState.Added; _context.SaveChanges(); return(true); } } else { var oldVersionEntity = GetTestimonialById(entity.Id); if (oldVersionEntity.ClientId != entity.ClientId) { if (!ContainsTestimonialByClientId(entity.ClientId)) { _context.Entry(entity).State = EntityState.Modified; _context.SaveChanges(); return(true); } else { _context.Entry(entity).State = EntityState.Modified; _context.SaveChanges(); return(true); } } } return(false); }
public bool SaveClient(Client entity) { if (entity.Id == default) { if (!ContainsClientByUserId(entity.UserId)) { _context.Entry(entity).State = EntityState.Added; _context.SaveChanges(); return(true); } } else { var oldVersionEntity = GetClientById(entity.Id); if (oldVersionEntity.UserId != entity.UserId) { if (!ContainsClientByUserId(entity.UserId)) { _context.Entry(entity).State = EntityState.Modified; _context.SaveChanges(); return(true); } } else { _context.Entry(entity).State = EntityState.Modified; _context.SaveChanges(); return(true); } } return(false); }
public bool SaveService(Service entity) { if (entity.Id == default) { if (!ContainsServiceByCategoryIdAndName(entity.CategoryId, entity.Name)) { _context.Entry(entity).State = EntityState.Added; _context.SaveChanges(); return(true); } } else { var oldVersionEntity = GetServiceById(entity.Id); if (oldVersionEntity.Name != entity.Name) { if (!ContainsServiceByCategoryIdAndName(entity.CategoryId, entity.Name)) { _context.Entry(entity).State = EntityState.Modified; _context.SaveChanges(); return(true); } } else { _context.Entry(entity).State = EntityState.Modified; _context.SaveChanges(); return(true); } } return(false); }