private void Validate(incrementtype incrementType) { if (String.IsNullOrEmpty(incrementType.incrementTypeDescription)) { throw new InvalidInputException("Increment description is required."); } }
public int Add(incrementtype incrementType) { var lastId = _db.incrementtypes.Max(i => i.incrementTypeId); incrementType.incrementTypeId = lastId + 1; _db.incrementtypes.Add(incrementType); _db.SaveChanges(); return(incrementType.incrementTypeId); }
public void Update(incrementtype incrementType, int id) { var incrementTypeToUpdate = FindOne(id); if (incrementTypeToUpdate == null) { return; } incrementTypeToUpdate = incrementType; _db.SaveChanges(); }
//Validation will take place in the other Add method's Validate method //And in IncrementService validate public void Add(ReminderAggregate reminderAggregate) { var reminder = new reminder() { reminderDate = reminderAggregate.ReminderDate, remindercol = reminderAggregate.ReminderCol, createdBy = _authRepository.Username }; var incrementType = new incrementtype() { incrementTypeDescription = reminderAggregate.IncrementDescription }; var incrementId = incrementService.Add(incrementType); reminder.snoozeIncrementTypeId = incrementId; Add(reminder); }
public void Update(incrementtype incrementType, int id) { Validate(incrementType); FindOne(id); _repository.Update(incrementType, id); }
public int Add(incrementtype incrementType) { Validate(incrementType); return(_repository.Add(incrementType)); }