public NotificationTemplate Create(NotificationTemplate notificationTemplate) { using (var repository = _repositoryFactory()) { var origEntity = repository.GetNotificationTemplateByNotification(notificationTemplate.NotificationTypeId, notificationTemplate.ObjectId, notificationTemplate.ObjectTypeId, notificationTemplate.Language); if (origEntity == null) { origEntity = notificationTemplate.ToDataModel(); repository.Add(origEntity); CommitChanges(repository); } var retVal = GetById(origEntity.Id); return(retVal); } }